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.v2; 017 018import org.gbif.api.model.checklistbank.NameUsageMatch; 019import org.gbif.api.vocabulary.TaxonomicStatus; 020 021import java.util.ArrayList; 022import java.util.List; 023import java.util.Objects; 024 025/** 026 * NameUsageMatch for API v2 027 * See https://github.com/gbif/checklistbank/issues/49 028 */ 029public class NameUsageMatch2 { 030 private boolean synonym; 031 private RankedName usage; 032 private RankedName acceptedUsage; 033 private Nomenclature nomenclature; 034 private List<RankedName> classification = new ArrayList<>(); 035 private Diagnostics diagnostics = new Diagnostics(); 036 037 public static class Nomenclature { 038 private String source; 039 private String id; 040 041 public String getSource() { 042 return source; 043 } 044 045 public void setSource(String source) { 046 this.source = source; 047 } 048 049 public String getId() { 050 return id; 051 } 052 053 public void setId(String id) { 054 this.id = id; 055 } 056 057 @Override 058 public boolean equals(Object o) { 059 if (this == o) return true; 060 if (o == null || getClass() != o.getClass()) return false; 061 Nomenclature that = (Nomenclature) o; 062 return Objects.equals(source, that.source) && 063 Objects.equals(id, that.id); 064 } 065 066 @Override 067 public int hashCode() { 068 return Objects.hash(source, id); 069 } 070 } 071 072 public static class Diagnostics { 073 private NameUsageMatch.MatchType matchType; 074 private Integer confidence; 075 private TaxonomicStatus status; 076 private List<String> lineage = new ArrayList<>(); 077 private List<NameUsageMatch2> alternatives = new ArrayList<>(); 078 private String note; 079 080 public NameUsageMatch.MatchType getMatchType() { 081 return matchType; 082 } 083 084 public void setMatchType(NameUsageMatch.MatchType matchType) { 085 this.matchType = matchType; 086 } 087 088 public Integer getConfidence() { 089 return confidence; 090 } 091 092 public void setConfidence(Integer confidence) { 093 this.confidence = confidence; 094 } 095 096 public TaxonomicStatus getStatus() { 097 return status; 098 } 099 100 public void setStatus(TaxonomicStatus status) { 101 this.status = status; 102 } 103 104 public List<String> getLineage() { 105 return lineage; 106 } 107 108 public void setLineage(List<String> lineage) { 109 this.lineage = lineage; 110 } 111 112 public List<NameUsageMatch2> getAlternatives() { 113 return alternatives; 114 } 115 116 public void setAlternatives(List<NameUsageMatch2> alternatives) { 117 this.alternatives = alternatives; 118 } 119 120 public String getNote() { 121 return note; 122 } 123 124 public void setNote(String note) { 125 this.note = note; 126 } 127 128 @Override 129 public boolean equals(Object o) { 130 if (this == o) return true; 131 if (o == null || getClass() != o.getClass()) return false; 132 Diagnostics that = (Diagnostics) o; 133 return status == that.status && 134 matchType == that.matchType && 135 Objects.equals(confidence, that.confidence) && 136 Objects.equals(lineage, that.lineage) && 137 Objects.equals(alternatives, that.alternatives) && 138 Objects.equals(note, that.note); 139 } 140 141 @Override 142 public int hashCode() { 143 return Objects.hash(status, matchType, confidence, lineage, alternatives, note); 144 } 145 } 146 147 public boolean isSynonym() { 148 return synonym; 149 } 150 151 public void setSynonym(boolean synonym) { 152 this.synonym = synonym; 153 } 154 155 public RankedName getUsage() { 156 return usage; 157 } 158 159 public void setUsage(RankedName usage) { 160 this.usage = usage; 161 } 162 163 public RankedName getAcceptedUsage() { 164 return acceptedUsage; 165 } 166 167 public void setAcceptedUsage(RankedName acceptedUsage) { 168 this.acceptedUsage = acceptedUsage; 169 } 170 171 public Nomenclature getNomenclature() { 172 return nomenclature; 173 } 174 175 public void setNomenclature(Nomenclature nomenclature) { 176 this.nomenclature = nomenclature; 177 } 178 179 /** 180 * the classification includes the accepted taxon concept view 181 */ 182 public List<RankedName> getClassification() { 183 return classification; 184 } 185 186 public void setClassification(List<RankedName> classification) { 187 this.classification = classification; 188 } 189 190 public Diagnostics getDiagnostics() { 191 return diagnostics; 192 } 193 194 public void setDiagnostics(Diagnostics diagnostics) { 195 this.diagnostics = diagnostics; 196 } 197 198 @Override 199 public boolean equals(Object o) { 200 if (this == o) return true; 201 if (o == null || getClass() != o.getClass()) return false; 202 NameUsageMatch2 that = (NameUsageMatch2) o; 203 return synonym == that.synonym && 204 Objects.equals(usage, that.usage) && 205 Objects.equals(acceptedUsage, that.acceptedUsage) && 206 Objects.equals(nomenclature, that.nomenclature) && 207 Objects.equals(classification, that.classification) && 208 Objects.equals(diagnostics, that.diagnostics); 209 } 210 211 @Override 212 public int hashCode() { 213 return Objects.hash(synonym, usage, acceptedUsage, nomenclature, classification, diagnostics); 214 } 215}