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.collections.duplicates;
017
018import org.gbif.api.vocabulary.Country;
019
020import java.io.Serializable;
021import java.util.Objects;
022import java.util.UUID;
023
024/** Models a duplicate in GRSciColl. It's used for institutions and collections. */
025public class Duplicate implements Serializable {
026
027  private UUID key;
028  private String code;
029  private String name;
030  private Country physicalCountry;
031  private String physicalCity;
032  private Country mailingCountry;
033  private String mailingCity;
034  private boolean active;
035  private boolean isIh;
036  private boolean isIdigbio;
037
038  // only for collections
039  private UUID institutionKey;
040
041  public UUID getKey() {
042    return key;
043  }
044
045  public void setKey(UUID key) {
046    this.key = key;
047  }
048
049  public String getCode() {
050    return code;
051  }
052
053  public void setCode(String code) {
054    this.code = code;
055  }
056
057  public String getName() {
058    return name;
059  }
060
061  public void setName(String name) {
062    this.name = name;
063  }
064
065  public Country getPhysicalCountry() {
066    return physicalCountry;
067  }
068
069  public void setPhysicalCountry(Country physicalCountry) {
070    this.physicalCountry = physicalCountry;
071  }
072
073  public String getPhysicalCity() {
074    return physicalCity;
075  }
076
077  public void setPhysicalCity(String physicalCity) {
078    this.physicalCity = physicalCity;
079  }
080
081  public Country getMailingCountry() {
082    return mailingCountry;
083  }
084
085  public void setMailingCountry(Country mailingCountry) {
086    this.mailingCountry = mailingCountry;
087  }
088
089  public String getMailingCity() {
090    return mailingCity;
091  }
092
093  public void setMailingCity(String mailingCity) {
094    this.mailingCity = mailingCity;
095  }
096
097  public boolean isActive() {
098    return active;
099  }
100
101  public void setActive(boolean active) {
102    this.active = active;
103  }
104
105  public boolean isIh() {
106    return isIh;
107  }
108
109  public void setIh(boolean ih) {
110    isIh = ih;
111  }
112
113  public boolean isIdigbio() {
114    return isIdigbio;
115  }
116
117  public void setIdigbio(boolean idigbio) {
118    isIdigbio = idigbio;
119  }
120
121  public UUID getInstitutionKey() {
122    return institutionKey;
123  }
124
125  public void setInstitutionKey(UUID institutionKey) {
126    this.institutionKey = institutionKey;
127  }
128
129  @Override
130  public boolean equals(Object o) {
131    if (this == o) {
132      return true;
133    }
134    if (o == null || getClass() != o.getClass()) {
135      return false;
136    }
137    Duplicate duplicate = (Duplicate) o;
138    return active == duplicate.active
139        && isIh == duplicate.isIh
140        && isIdigbio == duplicate.isIdigbio
141        && Objects.equals(key, duplicate.key)
142        && Objects.equals(code, duplicate.code)
143        && Objects.equals(name, duplicate.name)
144        && physicalCountry == duplicate.physicalCountry
145        && Objects.equals(physicalCity, duplicate.physicalCity)
146        && mailingCountry == duplicate.mailingCountry
147        && Objects.equals(mailingCity, duplicate.mailingCity)
148        && Objects.equals(institutionKey, duplicate.institutionKey);
149  }
150
151  @Override
152  public int hashCode() {
153    return Objects.hash(
154        key,
155        code,
156        name,
157        physicalCountry,
158        physicalCity,
159        mailingCountry,
160        mailingCity,
161        active,
162        isIh,
163        isIdigbio,
164        institutionKey);
165  }
166}