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 java.io.Serializable;
019
020import com.google.common.base.Objects;
021
022
023/**
024 * The base class of all curatorial units.
025 */
026public class CuratorialUnit implements Serializable {
027
028  private static final long serialVersionUID = 2359062014051953305L;
029
030  private CuratorialUnitType type;
031  private String typeVerbatim;
032
033  protected CuratorialUnit() {
034  }
035
036  protected CuratorialUnit(CuratorialUnitType type, String typeVerbatim) {
037    this.type = type;
038    this.typeVerbatim = typeVerbatim;
039  }
040
041  public CuratorialUnitType getType() {
042    return type;
043  }
044
045  public void setType(CuratorialUnitType type) {
046    this.type = type;
047  }
048
049  public String getTypeVerbatim() {
050    return typeVerbatim;
051  }
052
053  public void setTypeVerbatim(String typeVerbatim) {
054    this.typeVerbatim = typeVerbatim;
055  }
056
057  @Override
058  public boolean equals(Object obj) {
059    if (this == obj) {
060      return true;
061    }
062    if (!(obj instanceof CuratorialUnit)) {
063      return false;
064    }
065    if (!super.equals(obj)) {
066      return false;
067    }
068
069    CuratorialUnit that = (CuratorialUnit) obj;
070    return Objects.equal(this.type, that.type) && Objects.equal(this.typeVerbatim, that.typeVerbatim);
071  }
072
073  @Override
074  public int hashCode() {
075    return Objects.hashCode(super.hashCode(), type, typeVerbatim);
076  }
077
078  @Override
079  public String toString() {
080    return Objects.toStringHelper(this)
081      .add("super", super.toString())
082      .add("type", type)
083      .add("typeVerbatim", typeVerbatim)
084      .toString();
085  }
086
087}