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 public String key() { 036 return key; 037 } 038 039 public MockSourceFile setKey(String key) { 040 this.key = key; 041 return this; 042 } 043 044 @Override 045 public String path() { 046 return path; 047 } 048 049 public MockSourceFile setPath(String path) { 050 this.path = path; 051 return this; 052 } 053 054 public String qualifier() { 055 return qualifier; 056 } 057 058 public MockSourceFile setQualifier(String qualifier) { 059 this.qualifier = qualifier; 060 return this; 061 } 062 063 public String language() { 064 return language; 065 } 066 067 public MockSourceFile setLanguage(String language) { 068 this.language = language; 069 return this; 070 } 071 072 public String name() { 073 return name; 074 } 075 076 public MockSourceFile setName(String name) { 077 this.name = name; 078 return this; 079 } 080 081 public String longName() { 082 return longName; 083 } 084 085 public MockSourceFile setLongName(String longName) { 086 this.longName = longName; 087 return this; 088 } 089 090 @Override 091 public boolean equals(Object o) { 092 if (this == o) { 093 return true; 094 } 095 if (o == null || getClass() != o.getClass()) { 096 return false; 097 } 098 099 MockSourceFile that = (MockSourceFile) o; 100 return !(key != null ? !key.equals(that.key) : that.key != null); 101 } 102 103 @Override 104 public int hashCode() { 105 return key != null ? key.hashCode() : 0; 106 } 107 108 public static MockSourceFile createMain(String key) { 109 return new MockSourceFile().setKey(key).setQualifier("FIL"); 110 } 111 }