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; 017 018import java.io.Serializable; 019import java.util.Objects; 020import java.util.StringJoiner; 021 022/** 023 * Models a GrSciColl alternative code. 024 * 025 * <p>It contains the code and a description to specify why this code exists. 026 */ 027public class AlternativeCode implements Serializable { 028 029 private String code; 030 private String description; 031 032 public AlternativeCode() {} 033 034 public AlternativeCode(String code, String description) { 035 this.code = code; 036 this.description = description; 037 } 038 039 public String getCode() { 040 return code; 041 } 042 043 public void setCode(String code) { 044 this.code = code; 045 } 046 047 public String getDescription() { 048 return description; 049 } 050 051 public void setDescription(String description) { 052 this.description = description; 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 AlternativeCode that = (AlternativeCode) o; 064 return Objects.equals(code, that.code) && Objects.equals(description, that.description); 065 } 066 067 @Override 068 public int hashCode() { 069 return Objects.hash(code, description); 070 } 071 072 @Override 073 public String toString() { 074 return new StringJoiner(", ", AlternativeCode.class.getSimpleName() + "[", "]") 075 .add("code='" + code + "'") 076 .add("description='" + description + "'") 077 .toString(); 078 } 079}