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 to indicate that the curatorial unit falls within a range of values.
023 */
024public class CuratorialUnitRange extends CuratorialUnit {
025  private static final long serialVersionUID = 6558580719534069911L;
026
027  private int lower;
028  private int upper;
029
030  public CuratorialUnitRange() {
031  }
032
033  public CuratorialUnitRange(CuratorialUnitType type, String typeVerbatim, int lower, int upper) {
034    super(type, typeVerbatim);
035    this.lower = lower;
036    this.upper = upper;
037  }
038
039  public int getLower() {
040    return lower;
041  }
042
043  public void setLower(int lower) {
044    this.lower = lower;
045  }
046
047  public int getUpper() {
048    return upper;
049  }
050
051  public void setUpper(int upper) {
052    this.upper = upper;
053  }
054
055  @Override
056  public boolean equals(Object o) {
057    if (this == o) {
058      return true;
059    }
060    if (o == null || getClass() != o.getClass()) {
061      return false;
062    }
063    if (!super.equals(o)) {
064      return false;
065    }
066    CuratorialUnitRange that = (CuratorialUnitRange) o;
067    return lower == that.lower &&
068      upper == that.upper;
069  }
070
071  @Override
072  public int hashCode() {
073    return Objects.hash(super.hashCode(), lower, upper);
074  }
075
076  @Override
077  public String toString() {
078    return new StringJoiner(", ", CuratorialUnitRange.class.getSimpleName() + "[", "]")
079      .add("lower=" + lower)
080      .add("upper=" + upper)
081      .toString();
082  }
083}