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.registry.eml;
017
018import org.gbif.api.model.common.InterpretedEnum;
019import org.gbif.api.vocabulary.Rank;
020
021import java.io.Serializable;
022
023import com.google.common.base.Objects;
024
025
026/**
027 * An individual coverage.
028 */
029public class TaxonomicCoverage implements Serializable {
030
031  private static final long serialVersionUID = 7567059548990081342L;
032
033  private String scientificName;
034
035  private String commonName;
036
037  private InterpretedEnum<String, Rank> rank;
038
039  public TaxonomicCoverage() {
040  }
041
042  public TaxonomicCoverage(String scientificName, String commonName, InterpretedEnum<String, Rank> rank) {
043    this.scientificName = scientificName;
044    this.commonName = commonName;
045    this.rank = rank;
046  }
047
048  public String getCommonName() {
049    return commonName;
050  }
051
052  public void setCommonName(String commonName) {
053    this.commonName = commonName;
054  }
055
056  public InterpretedEnum<String, Rank> getRank() {
057    return rank;
058  }
059
060  public void setRank(InterpretedEnum<String, Rank> rank) {
061    this.rank = rank;
062  }
063
064  public String getScientificName() {
065    return scientificName;
066  }
067
068  public void setScientificName(String scientificName) {
069    this.scientificName = scientificName;
070  }
071
072  @Override
073  public boolean equals(Object obj) {
074    if (this == obj) {
075      return true;
076    }
077    if (!(obj instanceof TaxonomicCoverage)) {
078      return false;
079    }
080
081    TaxonomicCoverage
082      that = (TaxonomicCoverage) obj;
083    return Objects.equal(this.scientificName, that.scientificName)
084           && Objects.equal(this.commonName, that.commonName)
085           && Objects.equal(this.rank, that.rank);
086  }
087
088  @Override
089  public int hashCode() {
090    return Objects.hashCode(scientificName, commonName, rank);
091  }
092
093  @Override
094  public String toString() {
095    return "TaxonomicCoverage{" +
096           "scientificName='" + scientificName + '\'' +
097           ", commonName='" + commonName + '\'' +
098           ", rank=" + rank +
099           '}';
100  }
101
102}