001/*
002 * Copyright 2014 Global Biodiversity Information Facility (GBIF)
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *     http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016package org.gbif.api.model.checklistbank;
017
018import org.gbif.api.vocabulary.Language;
019
020import javax.annotation.Nullable;
021
022import com.google.common.base.Objects;
023
024
025/**
026 * Description Model Object represents a taxon description.
027 *
028 * @see <a href="http://rs.gbif.org/extension/gbif/1.0/description.xml">Description Definition</a>
029 */
030public class Description implements NameUsageExtension {
031
032  private Integer key;
033  private Integer taxonKey;
034  private String type;
035  private Language language;
036  private String description;
037  private String source;
038  private Integer sourceTaxonKey;
039  private String creator;
040  private String contributor;
041  private String license;
042
043  /**
044   * A unique GBIF identifier for any description.
045   * This key is used in the table of contents to retrieve the detailed description.
046   */
047  public Integer getKey() {
048    return key;
049  }
050
051  public void setKey(Integer key) {
052    this.key = key;
053  }
054
055  /**
056   * The name usage "taxon" key this description belongs to.
057   */
058  @Override
059  public Integer getTaxonKey() {
060    return taxonKey;
061  }
062
063  @Override
064  public void setTaxonKey(Integer taxonKey) {
065    this.taxonKey = taxonKey;
066  }
067
068  /**
069   * An entity responsible for making contributions to the textual information provided for a description.
070   *
071   * @return the contributor
072   */
073  @Nullable
074  public String getContributor() {
075    return contributor;
076  }
077
078  /**
079   * @param contributor the contributor to set
080   */
081  public void setContributor(String contributor) {
082    this.contributor = contributor;
083  }
084
085  /**
086   * The author(s) of the textual information provided for a description.
087   *
088   * @return the creator
089   */
090  @Nullable
091  public String getCreator() {
092    return creator;
093  }
094
095  /**
096   * @param creator the creator to set.
097   */
098  public void setCreator(String creator) {
099    this.creator = creator;
100  }
101
102  /**
103   * Any descriptive free text matching the category given as dc:type. The text should be either plain text or
104   * formatted with basic html tags, i.e. h1-4,p,i,b,a,img,ul and li. All other tags should be removed.
105   *
106   * @return the description
107   */
108  @Nullable
109  public String getDescription() {
110    return description;
111  }
112
113  /**
114   * @param description the description to set
115   */
116  public void setDescription(String description) {
117    this.description = description;
118  }
119
120  /**
121   * ISO 639-1 language code used for the vernacular name value.
122   *
123   * @return the language
124   */
125  @Nullable
126  public Language getLanguage() {
127    return language;
128  }
129
130  /**
131   * @param language the language to set
132   */
133  public void setLanguage(Language language) {
134    this.language = language;
135  }
136
137  /**
138   * Official permission to do something with the resource. Please use Creative Commons URIs if you can. <br/>
139   * <blockquote>
140   * <p>
141   * <i>Example:</i> CC-BY
142   * </p>
143   * </blockquote>
144   *
145   * @return the license.
146   */
147  @Nullable
148  public String getLicense() {
149    return license;
150  }
151
152  /**
153   * @param license the license to set
154   */
155  public void setLicense(String license) {
156    this.license = license;
157  }
158
159  /**
160   * Source reference of this description, a URL or full publication citation.
161   *
162   * @return the source
163   */
164  @Nullable
165  @Override
166  public String getSource() {
167    return source;
168  }
169
170  /**
171   * @param source the source to set
172   */
173  @Override
174  public void setSource(String source) {
175    this.source = source;
176  }
177
178  @Nullable
179  @Override
180  public Integer getSourceTaxonKey() {
181    return sourceTaxonKey;
182  }
183
184  @Override
185  public void setSourceTaxonKey(Integer sourceTaxonKey) {
186    this.sourceTaxonKey = sourceTaxonKey;
187  }
188
189  /**
190   * Returns the type used to categorize paragraphs of a taxon description.
191   * Given the list of types is so broad, an Enum is not used to maintain it. Rather it is kept as plain text.
192   *
193   * @return the type
194   *
195   * @see <a href="http://rs.gbif.org/vocabulary/gbif/description_type.xml">Description type definition</a>
196   */
197  @Nullable
198  public String getType() {
199    return type;
200  }
201
202  /**
203   * @param type the type to set
204   */
205  public void setType(String type) {
206    this.type = type;
207  }
208
209  @Override
210  public boolean equals(Object object) {
211    if (this == object) {
212      return true;
213    }
214    if (!(object instanceof Description)) {
215      return false;
216    }
217
218    Description that = (Description) object;
219    return Objects.equal(this.type, that.type)
220           && Objects.equal(this.language, that.language)
221           && Objects.equal(this.description, that.description)
222           && Objects.equal(this.source, that.source)
223           && Objects.equal(this.sourceTaxonKey, that.sourceTaxonKey)
224           && Objects.equal(this.creator, that.creator)
225           && Objects.equal(this.contributor, that.contributor)
226           && Objects.equal(this.license, that.license);
227  }
228
229  @Override
230  public int hashCode() {
231    return Objects.hashCode(type, language, description, source, creator, contributor, license);
232  }
233
234  @Override
235  public String toString() {
236    return Objects.toStringHelper(this)
237      .add("type", type)
238      .add("language", language)
239      .add("description", description)
240      .add("source", source)
241      .add("sourceTaxonKey", sourceTaxonKey)
242      .add("creator", creator)
243      .add("contributor", contributor)
244      .add("license", license)
245      .toString();
246  }
247
248}