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 org.gbif.api.vocabulary.ContactType; 019 020import java.io.Serializable; 021import java.util.Objects; 022import java.util.Set; 023import java.util.StringJoiner; 024 025import javax.annotation.Nullable; 026 027/** 028 * A contact used to generate a dataset citation. 029 */ 030public class CitationContact implements Serializable { 031 032 private Integer key; 033 034 private String abbreviatedName; 035 036 @Nullable 037 private String firstName; 038 039 @Nullable 040 private String lastName; 041 042 private Set<ContactType> roles; 043 044 @Nullable 045 private Set<String> userId; 046 047 public CitationContact(){} 048 049 public CitationContact( 050 Integer key, 051 String abbreviatedName, 052 @Nullable String firstName, 053 @Nullable String lastName, 054 Set<ContactType> roles, 055 @Nullable Set<String> userId 056 ) { 057 this.key = key; 058 this.abbreviatedName = abbreviatedName; 059 this.firstName = firstName; 060 this.lastName = lastName; 061 this.roles = roles; 062 this.userId = userId; 063 } 064 065 /** 066 * Key associated to this contact. 067 */ 068 public Integer getKey() { 069 return key; 070 } 071 072 public void setKey(Integer key) { 073 this.key = key; 074 } 075 076 /** 077 * Abbreviated name used for the citation. 078 */ 079 public String getAbbreviatedName() { 080 return abbreviatedName; 081 } 082 083 public void setAbbreviatedName(String abbreviatedName) { 084 this.abbreviatedName = abbreviatedName; 085 } 086 087 /** 088 * Contact's first name. 089 */ 090 public String getFirstName() { 091 return firstName; 092 } 093 094 public void setFirstName(String firstName) { 095 this.firstName = firstName; 096 } 097 098 /** 099 * Contact's last name. 100 */ 101 public String getLastName() { 102 return lastName; 103 } 104 105 public void setLastName(String lastName) { 106 this.lastName = lastName; 107 } 108 109 /** 110 * Roles or contact type of this contact. 111 */ 112 public Set<ContactType> getRoles() { 113 return roles; 114 } 115 116 public void setRoles(Set<ContactType> roles) { 117 this.roles = roles; 118 } 119 120 /** 121 * GBIF Portal users associated to this contact. 122 */ 123 public Set<String> getUserId() { 124 return userId; 125 } 126 127 public void setUserId(Set<String> userId) { 128 this.userId = userId; 129 } 130 131 @Override 132 public boolean equals(Object o) { 133 if (this == o) { 134 return true; 135 } 136 if (o == null || getClass() != o.getClass()) { 137 return false; 138 } 139 CitationContact contact = (CitationContact) o; 140 return Objects.equals(key, contact.key) && Objects.equals(abbreviatedName, contact.abbreviatedName) && 141 Objects.equals(firstName, contact.firstName) && Objects.equals(lastName, contact.lastName) && 142 Objects.equals(roles, contact.roles) && Objects.equals(userId, contact.userId); 143 } 144 145 @Override 146 public int hashCode() { 147 return Objects.hash(key, abbreviatedName, firstName, lastName, roles, userId); 148 } 149 150 @Override 151 public String toString() { 152 return new StringJoiner(", ", CitationContact.class.getSimpleName() + "[", "]") 153 .add("key=" + key) 154 .add("abbreviatedName='" + abbreviatedName + "'") 155 .add("firstName='" + firstName + "'") 156 .add("lastName='" + lastName + "'") 157 .add("roles=" + roles) 158 .add("userId=" + userId) 159 .toString(); 160 } 161}