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 import org.apache.commons.lang.builder.ToStringBuilder;
023
024 public class Library extends Resource {
025
026 private String name;
027 private String description;
028 private String version;
029
030 public Library(String key, String version) {
031 setKey(key);
032 this.version = version;
033 }
034
035 public String getVersion() {
036 return version;
037 }
038
039 public Library setName(String name) {
040 this.name = name;
041 return this;
042 }
043
044 public Library setDescription(String description) {
045 this.description = description;
046 return this;
047 }
048
049 @Override
050 public String getName() {
051 return name;
052 }
053
054 @Override
055 public String getLongName() {
056 return null;
057 }
058
059 @Override
060 public String getDescription() {
061 return description;
062 }
063
064 @Override
065 public Language getLanguage() {
066 return null;
067 }
068
069 @Override
070 public String getScope() {
071 return Resource.SCOPE_PROJECT;
072 }
073
074 @Override
075 public String getQualifier() {
076 return Resource.QUALIFIER_LIB;
077 }
078
079 @Override
080 public Resource getParent() {
081 return null;
082 }
083
084 @Override
085 public boolean matchFilePattern(String antPattern) {
086 return false;
087 }
088
089 @Override
090 public boolean equals(Object o) {
091 if (this == o) {
092 return true;
093 }
094 if (o == null || getClass() != o.getClass()) {
095 return false;
096 }
097 Library library = (Library) o;
098 if (!getKey().equals(library.getKey())) {
099 return false;
100 }
101 return version.equals(library.version);
102
103 }
104
105 @Override
106 public int hashCode() {
107 int result = super.hashCode();
108 result = 31 * result + getKey().hashCode();
109 result = 31 * result + version.hashCode();
110 return result;
111 }
112
113 @Override
114 public String toString() {
115 return new ToStringBuilder(this)
116 .append("key", getKey())
117 .append("name", getName())
118 .append("version", version)
119 .toString();
120 }
121 }