001/* 002 * Sonar, open source software quality management tool. 003 * Copyright (C) 2008-2012 SonarSource 004 * mailto:contact AT sonarsource DOT com 005 * 006 * Sonar 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 * Sonar 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 017 * License along with Sonar; if not, write to the Free Software 018 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 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 qualifier; 027 private String language; 028 private String name; 029 private String longName; 030 031 private MockSourceFile() { 032 } 033 034 public String key() { 035 return key; 036 } 037 038 public MockSourceFile setKey(String key) { 039 this.key = key; 040 return this; 041 } 042 043 public String qualifier() { 044 return qualifier; 045 } 046 047 public MockSourceFile setQualifier(String qualifier) { 048 this.qualifier = qualifier; 049 return this; 050 } 051 052 public String language() { 053 return language; 054 } 055 056 public MockSourceFile setLanguage(String language) { 057 this.language = language; 058 return this; 059 } 060 061 public String name() { 062 return name; 063 } 064 065 public MockSourceFile setName(String name) { 066 this.name = name; 067 return this; 068 } 069 070 public String longName() { 071 return longName; 072 } 073 074 public MockSourceFile setLongName(String longName) { 075 this.longName = longName; 076 return this; 077 } 078 079 @Override 080 public boolean equals(Object o) { 081 if (this == o) { 082 return true; 083 } 084 if (o == null || getClass() != o.getClass()) { 085 return false; 086 } 087 088 MockSourceFile that = (MockSourceFile) o; 089 return !(key != null ? !key.equals(that.key) : that.key != null); 090 } 091 092 @Override 093 public int hashCode() { 094 return key != null ? key.hashCode() : 0; 095 } 096 097 public static MockSourceFile createMain(String key) { 098 return new MockSourceFile().setKey(key).setQualifier("FIL"); 099 } 100}