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.occurrence;
017
018import org.gbif.api.vocabulary.AgentIdentifierType;
019
020import java.util.Objects;
021import java.util.StringJoiner;
022
023import javax.validation.constraints.NotNull;
024
025public class AgentIdentifier {
026
027  private AgentIdentifierType type;
028  private String value;
029
030  public AgentIdentifier() {
031  }
032
033  public AgentIdentifier(AgentIdentifierType type, String value) {
034    this.type = type;
035    this.value = value;
036  }
037
038  public AgentIdentifier(String value) {
039    this.value = value;
040  }
041
042  public AgentIdentifierType getType() {
043    return type;
044  }
045
046  public AgentIdentifier setType(AgentIdentifierType type) {
047    this.type = type;
048    return this;
049  }
050
051  @NotNull
052  public String getValue() {
053    return value;
054  }
055
056  public AgentIdentifier setValue(String value) {
057    this.value = value;
058    return this;
059  }
060
061  @Override
062  public boolean equals(Object o) {
063    if (this == o) {
064      return true;
065    }
066    if (o == null || getClass() != o.getClass()) {
067      return false;
068    }
069    AgentIdentifier that = (AgentIdentifier) o;
070    return type == that.type &&
071      Objects.equals(value, that.value);
072  }
073
074  @Override
075  public int hashCode() {
076    return Objects.hash(type, value);
077  }
078
079  @Override
080  public String toString() {
081    return new StringJoiner(", ", AgentIdentifier.class.getSimpleName() + "[", "]")
082      .add("type=" + type)
083      .add("value='" + value + "'")
084      .toString();
085  }
086}