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  @Override
056  public String moduleKey() {
057    return moduleKey;
058  }
059
060  public MockSourceFile setModuleKey(String moduleKey) {
061    this.moduleKey = moduleKey;
062    return this;
063  }
064
065  public String qualifier() {
066    return qualifier;
067  }
068
069  public MockSourceFile setQualifier(String qualifier) {
070    this.qualifier = qualifier;
071    return this;
072  }
073
074  public String language() {
075    return language;
076  }
077
078  public MockSourceFile setLanguage(String language) {
079    this.language = language;
080    return this;
081  }
082
083  public String name() {
084    return name;
085  }
086
087  public MockSourceFile setName(String name) {
088    this.name = name;
089    return this;
090  }
091
092  public String longName() {
093    return longName;
094  }
095
096  public MockSourceFile setLongName(String longName) {
097    this.longName = longName;
098    return this;
099  }
100
101  @Override
102  public boolean equals(Object o) {
103    if (this == o) {
104      return true;
105    }
106    if (o == null || getClass() != o.getClass()) {
107      return false;
108    }
109
110    MockSourceFile that = (MockSourceFile) o;
111    return !(key != null ? !key.equals(that.key) : that.key != null);
112  }
113
114  @Override
115  public int hashCode() {
116    return key != null ? key.hashCode() : 0;
117  }
118
119  public static MockSourceFile createMain(String key) {
120    return new MockSourceFile().setKey(key).setQualifier("FIL");
121  }
122}