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 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 object) {
057    if (this == object) {
058      return true;
059    }
060    if (!(object instanceof CuratorialUnitRange)) {
061      return false;
062    }
063    if (!super.equals(object)) {
064      return false;
065    }
066
067    CuratorialUnitRange
068      that = (CuratorialUnitRange) object;
069    return Objects.equal(this.lower, that.lower) && Objects.equal(this.upper, that.upper);
070  }
071
072  @Override
073  public int hashCode() {
074    return Objects.hashCode(super.hashCode(), lower, upper);
075  }
076
077  @Override
078  public String toString() {
079    return Objects.toStringHelper(this)
080      .add("super", super.toString())
081      .add("lower", lower)
082      .add("upper", upper)
083      .toString();
084  }
085
086}