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