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 javax.annotation.Nullable;
019
020import com.google.common.base.Objects;
021
022
023/**
024 * SpeciesProfile Model Object represents a species profile which describes basic species characteristics.
025 *
026 * @see <a href="http://rs.gbif.org/extension/gbif/1.0/speciesprofile.xml">Species Profile Definition</a>
027 */
028public class SpeciesProfile implements NameUsageExtension {
029
030  private Integer taxonKey;
031  private String livingPeriod;
032  private String lifeForm;
033  private String habitat;
034  private Boolean marine;
035  private Boolean freshwater;
036  private Boolean terrestrial;
037  private Boolean extinct;
038  private Boolean hybrid;
039  private Integer ageInDays;
040  private Integer sizeInMillimeter;
041  private Integer massInGram;
042  private String source;
043  private Integer sourceTaxonKey;
044
045  /**
046   * The name usage "taxon" key this description belongs to.
047   */
048  @Override
049  public Integer getTaxonKey() {
050    return taxonKey;
051  }
052
053  @Override
054  public void setTaxonKey(Integer taxonKey) {
055    this.taxonKey = taxonKey;
056  }
057
058  /**
059   * Maximum observed age of an organism given as number of days.
060   * <blockquote>
061   * <p>
062   * <i>Example:</i> 5.
063   * </p>
064   * </blockquote>
065   *
066   * @return the ageInDays
067   */
068  @Nullable
069  public Integer getAgeInDays() {
070    return ageInDays;
071  }
072
073  /**
074   * @param ageInDays the ageInDays to set
075   */
076  public void setAgeInDays(Integer ageInDays) {
077    this.ageInDays = ageInDays;
078  }
079
080  /**
081   * A Boolean flag indicating whether the taxon is a freshwater organism.
082   *
083   * @return freshwater flag
084   */
085  @Nullable
086  public Boolean isFreshwater() {
087    return freshwater;
088  }
089
090  public void setFreshwater(Boolean freshwater) {
091    this.freshwater = freshwater;
092  }
093
094  /**
095   * Comma seperated list of mayor habitat classification as defined by IUCN in which a species is known to exist:
096   * <a href="http://www.iucnredlist.org/static/major_habitats">http://www.iucnredlist.org/static/major_habitats</a>
097   * <blockquote>
098   * <p>
099   * <i>Example:</i> 1.1.
100   * </p>
101   * </blockquote>
102   *
103   * @return the habitat
104   */
105  @Nullable
106  public String getHabitat() {
107    return habitat;
108  }
109
110  /**
111   * @param habitat the habitat to set.
112   */
113  public void setHabitat(String habitat) {
114    this.habitat = habitat;
115  }
116
117  /**
118   * A term describing the growth/lifeform of an organism. Should be based on a vocabulary like Raunkiær for plants:
119   * <a href="http://en.wikipedia.org/wiki/Raunkiær_plant_life-form">http://en.wikipedia.org/wiki/Raunkiær_plant_life-
120   * form</a>. Recommended vocabulary:
121   * <a href="http://rs.gbif.org/vocabulary/gbif/life_form.xml">http://rs.gbif.org/vocabulary/gbif/life_form.xml</a>
122   * <blockquote>
123   * <p>
124   * <i>Example:</i> Phanerophyte.
125   * </p>
126   * </blockquote>
127   *
128   * @return the lifeForm
129   */
130  @Nullable
131  public String getLifeForm() {
132    return lifeForm;
133  }
134
135  /**
136   * @param lifeForm the lifeForm to set
137   */
138  public void setLifeForm(String lifeForm) {
139    this.lifeForm = lifeForm;
140  }
141
142  /**
143   * The (geological) time a currently extinct organism is known to have lived. For geological times of fossils ideally
144   * based on a vocabulary like <a
145   * href="http://en.wikipedia.org/wiki/Geologic_column">http://en.wikipedia.org/wiki/Geologic_column</a>
146   * <blockquote>
147   * <p>
148   * <i>Example:</i> Cretaceous.
149   * </p>
150   * </blockquote>
151   *
152   * @return the livingPeriod
153   */
154  @Nullable
155  public String getLivingPeriod() {
156    return livingPeriod;
157  }
158
159  /**
160   * @param livingPeriod the livingPeriod to set
161   */
162  public void setLivingPeriod(String livingPeriod) {
163    this.livingPeriod = livingPeriod;
164  }
165
166  /**
167   * Maximum observed weight of an organism in grams.
168   * <blockquote>
169   * <p>
170   * <i>Example:</i> 12.
171   * </p>
172   * </blockquote>
173   *
174   * @return the massInGram
175   */
176  @Nullable
177  public Integer getMassInGram() {
178    return massInGram;
179  }
180
181  /**
182   * @param massInGram the massInGram to set
183   */
184  public void setMassInGram(Integer massInGram) {
185    this.massInGram = massInGram;
186  }
187
188  /**
189   * Maximum observed size of an organism in millimeter. Can be either height, length or width, whichever is greater.
190   * <blockquote>
191   * <p>
192   * <i>Example:</i> 1500.
193   * </p>
194   * </blockquote>
195   *
196   * @return the sizeInMillimeter
197   */
198  @Nullable
199  public Integer getSizeInMillimeter() {
200    return sizeInMillimeter;
201  }
202
203  /**
204   * @param sizeInMillimeter the sizeInMillimeter to se
205   */
206  public void setSizeInMillimeter(Integer sizeInMillimeter) {
207    this.sizeInMillimeter = sizeInMillimeter;
208  }
209
210  /**
211   * Flag indicating an extinct organism. Details about the timeperiod the organism has lived in can be supplied below.
212   * <blockquote>
213   * <p>
214   * <i>Example:</i> true - false.
215   * </p>
216   * </blockquote>
217   *
218   * @return the extinct
219   */
220  @Nullable
221  public Boolean isExtinct() {
222    return extinct;
223  }
224
225  /**
226   * @param extinct the extinct to set
227   */
228  public void setExtinct(Boolean extinct) {
229    this.extinct = extinct;
230  }
231
232  /**
233   * Flag indicating a hybrid organism. This does not have to be reflected in the name, but can be based on other
234   * studies like chromosome numbers etc.
235   * <blockquote>
236   * <p>
237   * <i>Example:</i> true - false.
238   * </p>
239   * </blockquote>
240   *
241   * @return the hybrid
242   */
243  @Nullable
244  public Boolean isHybrid() {
245    return hybrid;
246  }
247
248  /**
249   * @param hybrid the hybrid to set
250   */
251  public void setHybrid(Boolean hybrid) {
252    this.hybrid = hybrid;
253  }
254
255  /**
256   * A Boolean flag indicating whether the taxon is a marine organism, i.e. can be found in/above sea water
257   * <blockquote>
258   * <p>
259   * <i>Example:</i> true - false.
260   * </p>
261   * </blockquote>
262   *
263   * @return is marine flag
264   */
265  @Nullable
266  public Boolean isMarine() {
267    return marine;
268  }
269
270  /**
271   * @param marine the marine to set
272   */
273  public void setMarine(Boolean marine) {
274    this.marine = marine;
275  }
276
277  /**
278   * A Boolean flag indicating the taxon is a terrestial organism, i.e. occurrs on land as opposed to the sea.
279   * <blockquote>
280   * <p>
281   * <i>Example:</i> true - false.
282   * </p>
283   * </blockquote>
284   *
285   * @return the terrestrial
286   */
287  @Nullable
288  public Boolean isTerrestrial() {
289    return terrestrial;
290  }
291
292  /**
293   * @param terrestrial the terrestrial to set
294   */
295  public void setTerrestrial(Boolean terrestrial) {
296    this.terrestrial = terrestrial;
297  }
298
299  @Nullable
300  @Override
301  public String getSource() {
302    return source;
303  }
304
305  @Override
306  public void setSource(String source) {
307    this.source = source;
308  }
309
310  @Nullable
311  @Override
312  public Integer getSourceTaxonKey() {
313    return sourceTaxonKey;
314  }
315
316  @Override
317  public void setSourceTaxonKey(Integer sourceTaxonKey) {
318    this.sourceTaxonKey = sourceTaxonKey;
319  }
320
321  @Override
322  public boolean equals(Object object) {
323    if (this == object) {
324      return true;
325    }
326    if (!(object instanceof SpeciesProfile)) {
327      return false;
328    }
329
330    SpeciesProfile that = (SpeciesProfile) object;
331    return Objects.equal(this.livingPeriod, that.livingPeriod)
332           && Objects.equal(this.lifeForm, that.lifeForm)
333           && Objects.equal(this.habitat, that.habitat)
334           && Objects.equal(this.marine, that.marine)
335           && Objects.equal(this.terrestrial, that.terrestrial)
336           && Objects.equal(this.extinct, that.extinct)
337           && Objects.equal(this.hybrid, that.hybrid)
338           && Objects.equal(this.ageInDays, that.ageInDays)
339           && Objects.equal(this.sizeInMillimeter, that.sizeInMillimeter)
340           && Objects.equal(this.massInGram, that.massInGram)
341           && Objects.equal(this.source, that.source)
342           && Objects.equal(this.sourceTaxonKey, that.sourceTaxonKey);
343  }
344
345  @Override
346  public int hashCode() {
347    return Objects.hashCode(livingPeriod,
348                            lifeForm,
349                            habitat,
350                            marine,
351                            terrestrial,
352                            extinct,
353                            hybrid,
354                            ageInDays,
355                            sizeInMillimeter,
356                            massInGram,
357                            source,
358                            sourceTaxonKey);
359  }
360
361  @Override
362  public String toString() {
363    return Objects.toStringHelper(this)
364      .add("livingPeriod", livingPeriod)
365      .add("lifeForm", lifeForm)
366      .add("habitat", habitat)
367      .add("marine", marine)
368      .add("terrestrial", terrestrial)
369      .add("extinct", extinct)
370      .add("hybrid", hybrid)
371      .add("ageInDays", ageInDays)
372      .add("sizeInMillimeter", sizeInMillimeter)
373      .add("massInGram", massInGram)
374      .add("source", source)
375      .add("sourceTaxonKey", sourceTaxonKey)
376      .toString();
377  }
378
379}