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; 017 018import java.io.Serializable; 019import java.util.Objects; 020import java.util.StringJoiner; 021 022import javax.annotation.Nullable; 023import javax.validation.constraints.Size; 024 025/** 026 * A citation can have one or both of a textual component and an identifier which can be 027 * of any form, but expected to be resolvable in some way such as an LSID, DOI or similar. 028 */ 029public class Citation implements Serializable { 030 031 private static final long serialVersionUID = 5587531070690709593L; 032 033 @Nullable private String text; 034 035 @Nullable 036 @Size(min = 1, max = 100) 037 private String identifier; 038 039 private boolean citationProvidedBySource; 040 041 public Citation() {} 042 043 public Citation(String text, String identifier, boolean citationProvidedBySource) { 044 this.text = text; 045 this.identifier = identifier; 046 this.citationProvidedBySource = citationProvidedBySource; 047 } 048 049 public String getIdentifier() { 050 return identifier; 051 } 052 053 public void setIdentifier(String identifier) { 054 this.identifier = identifier; 055 } 056 057 public String getText() { 058 return text; 059 } 060 061 public void setText(String text) { 062 this.text = text; 063 } 064 065 public boolean isCitationProvidedBySource() { 066 return citationProvidedBySource; 067 } 068 069 public void setCitationProvidedBySource(boolean citationProvidedBySource) { 070 this.citationProvidedBySource = citationProvidedBySource; 071 } 072 073 @Override 074 public boolean equals(Object o) { 075 if (this == o) { 076 return true; 077 } 078 if (o == null || getClass() != o.getClass()) { 079 return false; 080 } 081 Citation citation = (Citation) o; 082 return Objects.equals(text, citation.text) && Objects.equals(identifier, citation.identifier) && 083 Objects.equals(citationProvidedBySource, citation.citationProvidedBySource); 084 } 085 086 @Override 087 public int hashCode() { 088 return Objects.hash(text, identifier, citationProvidedBySource); 089 } 090 091 @Override 092 public String toString() { 093 return new StringJoiner(", ", Citation.class.getSimpleName() + "[", "]") 094 .add("text='" + text + "'") 095 .add("identifier='" + identifier + "'") 096 .add("citationProvidedBySource='" + citationProvidedBySource + "'") 097 .toString(); 098 } 099}