001 /*
002 * Sonar, open source software quality management tool.
003 * Copyright (C) 2009 SonarSource SA
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 */
020 package org.sonar.api.resources;
021
022 public class Library extends Resource {
023
024 private String name;
025 private String description;
026 private String version;
027
028 public Library(String key, String version) {
029 setKey(key);
030 this.version = version;
031 }
032
033 public String getVersion() {
034 return version;
035 }
036
037 public Library setName(String name) {
038 this.name = name;
039 return this;
040 }
041
042 public Library setDescription(String description) {
043 this.description = description;
044 return this;
045 }
046
047 @Override
048 public String getName() {
049 return name;
050 }
051
052 @Override
053 public String getLongName() {
054 return null;
055 }
056
057 @Override
058 public String getDescription() {
059 return description;
060 }
061
062 @Override
063 public Language getLanguage() {
064 return null;
065 }
066
067 @Override
068 public String getScope() {
069 return Resource.SCOPE_PROJECT;
070 }
071
072 @Override
073 public String getQualifier() {
074 return Resource.QUALIFIER_LIB;
075 }
076
077 @Override
078 public Resource getParent() {
079 return null;
080 }
081
082 @Override
083 public boolean matchFilePattern(String antPattern) {
084 return false;
085 }
086
087 @Override
088 public boolean equals(Object o) {
089 if (this == o) {
090 return true;
091 }
092 if (o == null || getClass() != o.getClass()) {
093 return false;
094 }
095 Library library = (Library) o;
096 if (!getKey().equals(library.getKey())) {
097 return false;
098 }
099 return version.equals(library.version);
100
101 }
102
103 @Override
104 public int hashCode() {
105 int result = super.hashCode();
106 result = 31 * result + getKey().hashCode();
107 result = 31 * result + version.hashCode();
108 return result;
109 }
110 }