001/*
002 * Licensed under the Apache License, Version 2.0 (the "License");
003 * you may not use this file except in compliance with the License.
004 * You may obtain a copy of the License at
005 *
006 *     http://www.apache.org/licenses/LICENSE-2.0
007 *
008 * Unless required by applicable law or agreed to in writing, software
009 * distributed under the License is distributed on an "AS IS" BASIS,
010 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
011 * See the License for the specific language governing permissions and
012 * limitations under the License.
013 */
014package org.gbif.api.model.checklistbank;
015
016
017import org.gbif.api.vocabulary.Country;
018import org.gbif.api.vocabulary.Language;
019import org.gbif.api.vocabulary.LifeStage;
020import org.gbif.api.vocabulary.Sex;
021
022import java.util.Objects;
023import java.util.StringJoiner;
024
025import javax.annotation.Nullable;
026import javax.validation.constraints.NotNull;
027
028import io.swagger.v3.oas.annotations.media.Schema;
029
030/**
031 * VernacularName Model Object represents a vernacular name for a scientific taxon.
032 *
033 * @see <a href="http://rs.gbif.org/extension/gbif/1.0/vernacularname.xml">Vernacular Name
034 * Definition</a>
035 */
036@SuppressWarnings("unused")
037public class VernacularName implements NameUsageExtension {
038
039  private Integer taxonKey;
040  private String vernacularName;
041  private Language language;
042  private LifeStage lifeStage;
043  private Sex sex;
044  private Country country;
045  private String area;
046  private String source;
047  private Integer sourceTaxonKey;
048  private Boolean preferred;
049  private Boolean plural;
050
051  /**
052   * The name usage "taxon" key to which this vernacular name belongs.
053   */
054  @Schema(description = "The name usage “taxon“ key to which this vernacular name belongs.")
055  @Override
056  public Integer getTaxonKey() {
057    return taxonKey;
058  }
059
060  @Override
061  public void setTaxonKey(Integer taxonKey) {
062    this.taxonKey = taxonKey;
063  }
064
065  /**
066   * The area for the vernacular name.
067   *
068   * @return the area
069   */
070  @Schema(description = "The area where the vernacular name is used.")
071  @Nullable
072  public String getArea() {
073    return area;
074  }
075
076  /**
077   * @param area the area to set
078   */
079  public void setArea(String area) {
080    this.area = area;
081  }
082
083  /**
084   * The country in which the vernacular name is used.
085   *
086   * @return the country
087   */
088  @Schema(description = "The country or area in which the vernacular name is used.")
089  @Nullable
090  public Country getCountry() {
091    return country;
092  }
093
094  /**
095   * @param country the country to set
096   */
097  public void setCountry(Country country) {
098    this.country = country;
099  }
100
101  /**
102   * ISO 639-1 language code used for the vernacular name value.
103   * <blockquote>
104   * <p>
105   * <i>Example:</i> es
106   * </p>
107   * </blockquote>
108   *
109   * @return the language
110   */
111  @Nullable
112  @Schema(description = "The language (from ISO 639-1) of the vernacular name.")
113  public Language getLanguage() {
114    return language;
115  }
116
117  /**
118   * @param language the language to set
119   */
120  public void setLanguage(Language language) {
121    this.language = language;
122  }
123
124  /**
125   * The age class or life stage of the species for which the vernacular name applies. Best practice
126   * is to utilise a controlled list of terms for this value.
127   * <blockquote>
128   * <p>
129   * <i>Example:</i> "juvenile" is the life stage of the fish Pomatomus saltatrix for which the name
130   * "snapper blue"
131   * refers.
132   * </p>
133   * </blockquote>
134   *
135   * @return the lifeStage
136   * @see <a href="http://rs.gbif.org/vocabulary/gbif/life_stage.xml">Life Stage GBIF Vocabulary</a>
137   */
138  @Schema(description = "The age class or life stage of the species for which the vernacular name applies.\n\n" +
139    "For example, a juvenile *Anser anser* is called a “gosling“.")
140  @Nullable
141  public LifeStage getLifeStage() {
142    return lifeStage;
143  }
144
145  /**
146   * @param lifeStage the lifeStage to set
147   */
148  public void setLifeStage(LifeStage lifeStage) {
149    this.lifeStage = lifeStage;
150  }
151
152  /**
153   * The sex (gender) of the taxon for which the vernacular name applies when the vernacular name is
154   * limited to a specific gender of a species. If not limited sex should be empty. For example the
155   * vernacular name "Buck" applies to the "Male" gender of the species, Odocoileus virginianus.
156   * <blockquote>
157   * <p>
158   * <i>Example:</i> male.
159   * </p>
160   * </blockquote>
161   *
162   * @return the sex
163   * @see <a href="http://rs.gbif.org/vocabulary/gbif/sex.xml">Sex GBIF Vocabulary</a>
164   */
165  @Schema(description = "The sex of the taxon for which the vernacular name applies when the name is limited to a " +
166    "specific sex of a species.\n\n" +
167    "For example, “goose“ can refer to either male or female *Anser*, but only males may be called “gander”.")
168  @Nullable
169  public Sex getSex() {
170    return sex;
171  }
172
173  /**
174   * @param sex the sex to set
175   */
176  public void setSex(Sex sex) {
177    this.sex = sex;
178  }
179
180  /**
181   * Bibliographic citation referencing a source where the vernacular name refers to the cited
182   * species.
183   * <blockquote>
184   * <p>
185   * <i>Example:</i> Peterson Field Guide to the Eastern Seashore, Houghton Mifflin Co, 1961, p131.
186   * </p>
187   * </blockquote>
188   *
189   * @return the source
190   */
191  @Schema(description = "Bibliographic citation referencing a source where the vernacular name refers to the " +
192    "cited species.")
193  @Nullable
194  @Override
195  public String getSource() {
196    return source;
197  }
198
199  /**
200   * @param source the source to set
201   */
202  @Override
203  public void setSource(String source) {
204    this.source = source;
205  }
206
207  @Schema(description = "The name usage key of the taxon in the checklist including this vernacular name.")
208  @Nullable
209  @Override
210  public Integer getSourceTaxonKey() {
211    return sourceTaxonKey;
212  }
213
214  @Override
215  public void setSourceTaxonKey(Integer sourceTaxonKey) {
216    this.sourceTaxonKey = sourceTaxonKey;
217  }
218
219  /**
220   * A common or vernacular name.
221   * <blockquote>
222   * <p>
223   * <i>Example:</i> Andean Condor", "Condor Andino", "American Eagle", "Gänsegeier".
224   * </p>
225   * </blockquote>
226   *
227   * @return the vernacularName
228   */
229  @Schema(description = "A common or vernacular name.")
230  @NotNull
231  public String getVernacularName() {
232    return vernacularName;
233  }
234
235  /**
236   * @param vernacularName the vernacularName to set
237   */
238  public void setVernacularName(String vernacularName) {
239    this.vernacularName = vernacularName;
240  }
241
242  /**
243   * This value is true if the vernacular name it qualifies refers to a plural form of the name.
244   * <blockquote>
245   * <p>
246   * <i>Example:</i> The term "Schoolies" is the plural form of a name used along the coastal
247   * Northeastern U.S. for
248   * groups of juvenile fish of the species, Morone saxatilis.
249   * </p>
250   * </blockquote>
251   *
252   * @return the plural
253   * @see <a href="http://rs.gbif.org/vocabulary/basic/boolean.xml">Boolean Vocabulary</a>
254   */
255  @Schema(description = "True if the vernacular name refers to a plural form of the name.")
256  @Nullable
257  public Boolean isPlural() {
258    return plural;
259  }
260
261  /**
262   * @param plural the plural to set
263   */
264  public void setPlural(Boolean plural) {
265    this.plural = plural;
266  }
267
268  /**
269   * This term is true if the source citing the use of this vernacular name indicates the usage has
270   * some preference or specific standing over other possible vernacular names used for the
271   * species.
272   * <blockquote>
273   * <p>
274   * <i>Example:</i> Some organisations have attempted to assign specific and unique vernacular
275   * names for particular
276   * taxon groups in a systematic attempt to bring order and consistency to the use of these names.
277   * For example, the American Ornithological Union assigns the name "Pearl Kite" for the taxon,
278   * Gampsonyx swainsonii. The value of isPreferredName for this record would be true.
279   * </p>
280   * </blockquote>
281   *
282   * @return the preferred
283   * @see <a href="http://rs.gbif.org/vocabulary/basic/boolean.xml">Boolean Vocabulary</a>
284   */
285  @Schema(description = "This term is true if the source citing the use of this vernacular name indicates the usage " +
286    "has some preference or specific standing over other possible vernacular names used for the species.")
287  @Nullable
288  public Boolean isPreferred() {
289    return preferred;
290  }
291
292  /**
293   * @param preferred the preferred to set
294   */
295  public void setPreferred(Boolean preferred) {
296    this.preferred = preferred;
297  }
298
299  @Override
300  public boolean equals(Object o) {
301    if (this == o) {
302      return true;
303    }
304    if (o == null || getClass() != o.getClass()) {
305      return false;
306    }
307    VernacularName that = (VernacularName) o;
308    return Objects.equals(vernacularName, that.vernacularName) &&
309      language == that.language &&
310      lifeStage == that.lifeStage &&
311      sex == that.sex &&
312      country == that.country &&
313      Objects.equals(area, that.area) &&
314      Objects.equals(source, that.source) &&
315      Objects.equals(sourceTaxonKey, that.sourceTaxonKey) &&
316      Objects.equals(preferred, that.preferred) &&
317      Objects.equals(plural, that.plural);
318  }
319
320  @Override
321  public int hashCode() {
322    return Objects.hash(vernacularName, language, lifeStage, sex, country, area, source,
323      sourceTaxonKey, preferred, plural);
324  }
325
326  @Override
327  public String toString() {
328    return new StringJoiner(", ", VernacularName.class.getSimpleName() + "[", "]")
329      .add("vernacularName='" + vernacularName + "'")
330      .add("language=" + language)
331      .add("lifeStage=" + lifeStage)
332      .add("sex=" + sex)
333      .add("country=" + country)
334      .add("area='" + area + "'")
335      .add("source='" + source + "'")
336      .add("sourceTaxonKey=" + sourceTaxonKey)
337      .add("preferred=" + preferred)
338      .add("plural=" + plural)
339      .toString();
340  }
341}