001    /*
002     * SonarQube, open source software quality management tool.
003     * Copyright (C) 2008-2014 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     */
020    package org.sonar.api.component.mock;
021    
022    import org.sonar.api.component.SourceFile;
023    
024    public class MockSourceFile implements SourceFile {
025      private String key;
026      private String path;
027      private String qualifier;
028      private String language;
029      private String name;
030      private String longName;
031    
032      private MockSourceFile() {
033      }
034    
035      @Override
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 qualifier() {
057        return qualifier;
058      }
059    
060      public MockSourceFile setQualifier(String qualifier) {
061        this.qualifier = qualifier;
062        return this;
063      }
064    
065      public String language() {
066        return language;
067      }
068    
069      public MockSourceFile setLanguage(String language) {
070        this.language = language;
071        return this;
072      }
073    
074      @Override
075      public String name() {
076        return name;
077      }
078    
079      public MockSourceFile setName(String name) {
080        this.name = name;
081        return this;
082      }
083    
084      @Override
085      public String longName() {
086        return longName;
087      }
088    
089      public MockSourceFile setLongName(String longName) {
090        this.longName = longName;
091        return this;
092      }
093    
094      @Override
095      public boolean equals(Object o) {
096        if (this == o) {
097          return true;
098        }
099        if (o == null || getClass() != o.getClass()) {
100          return false;
101        }
102    
103        MockSourceFile that = (MockSourceFile) o;
104        return !(key != null ? !key.equals(that.key) : that.key != null);
105      }
106    
107      @Override
108      public int hashCode() {
109        return key != null ? key.hashCode() : 0;
110      }
111    
112      public static MockSourceFile createMain(String key) {
113        return new MockSourceFile().setKey(key).setQualifier("FIL");
114      }
115    }