001/* 002 * SonarQube, open source software quality management tool. 003 * Copyright (C) 2008-2013 SonarSource 004 * mailto:contact AT sonarsource DOT com 005 * 006 * SonarQube is free software; you can redistribute it and/or 007 * modify it under the terms of the GNU Lesser General Public 008 * License as published by the Free Software Foundation; either 009 * version 3 of the License, or (at your option) any later version. 010 * 011 * SonarQube is distributed in the hope that it will be useful, 012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 014 * Lesser General Public License for more details. 015 * 016 * You should have received a copy of the GNU Lesser General Public License 017 * along with this program; if not, write to the Free Software Foundation, 018 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 019 */ 020package org.sonar.api.component.mock; 021 022import org.sonar.api.component.SourceFile; 023 024public class MockSourceFile implements SourceFile { 025 private String key; 026 private String path; 027 private String moduleKey; 028 private String qualifier; 029 private String language; 030 private String name; 031 private String longName; 032 033 private MockSourceFile() { 034 } 035 036 public String key() { 037 return key; 038 } 039 040 public MockSourceFile setKey(String key) { 041 this.key = key; 042 return this; 043 } 044 045 @Override 046 public String path() { 047 return path; 048 } 049 050 public MockSourceFile setPath(String path) { 051 this.path = path; 052 return this; 053 } 054 055 public MockSourceFile setModuleKey(String moduleKey) { 056 this.moduleKey = moduleKey; 057 return this; 058 } 059 060 public String qualifier() { 061 return qualifier; 062 } 063 064 public MockSourceFile setQualifier(String qualifier) { 065 this.qualifier = qualifier; 066 return this; 067 } 068 069 public String language() { 070 return language; 071 } 072 073 public MockSourceFile setLanguage(String language) { 074 this.language = language; 075 return this; 076 } 077 078 public String name() { 079 return name; 080 } 081 082 public MockSourceFile setName(String name) { 083 this.name = name; 084 return this; 085 } 086 087 public String longName() { 088 return longName; 089 } 090 091 public MockSourceFile setLongName(String longName) { 092 this.longName = longName; 093 return this; 094 } 095 096 @Override 097 public boolean equals(Object o) { 098 if (this == o) { 099 return true; 100 } 101 if (o == null || getClass() != o.getClass()) { 102 return false; 103 } 104 105 MockSourceFile that = (MockSourceFile) o; 106 return !(key != null ? !key.equals(that.key) : that.key != null); 107 } 108 109 @Override 110 public int hashCode() { 111 return key != null ? key.hashCode() : 0; 112 } 113 114 public static MockSourceFile createMain(String key) { 115 return new MockSourceFile().setKey(key).setQualifier("FIL"); 116 } 117}