001/*
002 * Copyright 2020 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 java.util.Objects;
019import java.util.StringJoiner;
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 o) {
060    if (this == o) {
061      return true;
062    }
063    if (o == null || getClass() != o.getClass()) {
064      return false;
065    }
066    if (!super.equals(o)) {
067      return false;
068    }
069    CuratorialUnitCount that = (CuratorialUnitCount) o;
070    return count == that.count &&
071      deviation == that.deviation;
072  }
073
074  @Override
075  public int hashCode() {
076    return Objects.hash(super.hashCode(), count, deviation);
077  }
078
079  @Override
080  public String toString() {
081    return new StringJoiner(", ", CuratorialUnitCount.class.getSimpleName() + "[", "]")
082      .add("count=" + count)
083      .add("deviation=" + deviation)
084      .toString();
085  }
086}