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.curatorial;
017
018import com.google.common.base.Objects;
019
020
021/**
022 * Used for acuratorial unit count with uncertainty.
023 * E.g. 100000 +/- 1000.
024 */
025public class CuratorialUnitCount extends CuratorialUnit {
026
027  private static final long serialVersionUID = 6330209010528750428L;
028
029  private int count;
030
031  private int deviation;
032
033  public CuratorialUnitCount() {
034  }
035
036  public CuratorialUnitCount(CuratorialUnitType type, String typeVerbatim, int count, int deviation) {
037    super(type, typeVerbatim);
038    this.count = count;
039    this.deviation = deviation;
040  }
041
042  public int getCount() {
043    return count;
044  }
045
046  public void setCount(int count) {
047    this.count = count;
048  }
049
050  public int getDeviation() {
051    return deviation;
052  }
053
054  public void setDeviation(int deviation) {
055    this.deviation = deviation;
056  }
057
058  @Override
059  public boolean equals(Object object) {
060    if (this == object) {
061      return true;
062    }
063    if (!(object instanceof CuratorialUnitCount)) {
064      return false;
065    }
066    if (!super.equals(object)) {
067      return false;
068    }
069
070    CuratorialUnitCount
071      that = (CuratorialUnitCount) object;
072    return Objects.equal(this.count, that.count) && Objects.equal(this.deviation, that.deviation);
073  }
074
075  @Override
076  public int hashCode() {
077    return Objects.hashCode(super.hashCode(), count, deviation);
078  }
079
080  @Override
081  public String toString() {
082    return Objects.toStringHelper(this)
083      .add("super", super.toString())
084      .add("count", count)
085      .add("deviation", deviation)
086      .toString();
087  }
088
089}