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