001 /* 002 * SonarQube, open source software quality management tool. 003 * Copyright (C) 2008-2013 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.resources; 021 022 import org.apache.commons.lang.builder.ToStringBuilder; 023 024 public final 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 Scopes.PROJECT; 072 } 073 074 @Override 075 public String getQualifier() { 076 return Qualifiers.LIBRARY; 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 @Override 105 public int hashCode() { 106 int result = super.hashCode(); 107 result = 31 * result + getKey().hashCode(); 108 result = 31 * result + version.hashCode(); 109 return result; 110 } 111 112 @Override 113 public String toString() { 114 return new ToStringBuilder(this) 115 .append("key", getKey()) 116 .append("name", getName()) 117 .append("version", version) 118 .toString(); 119 } 120 }