001/*
002 * Licensed under the Apache License, Version 2.0 (the "License");
003 * you may not use this file except in compliance with the License.
004 * You may obtain a copy of the License at
005 *
006 *     http://www.apache.org/licenses/LICENSE-2.0
007 *
008 * Unless required by applicable law or agreed to in writing, software
009 * distributed under the License is distributed on an "AS IS" BASIS,
010 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
011 * See the License for the specific language governing permissions and
012 * limitations under the License.
013 */
014package org.gbif.api.model.collections;
015
016import java.io.Serializable;
017import java.util.Objects;
018import java.util.StringJoiner;
019
020import org.gbif.api.vocabulary.collections.IdType;
021
022import javax.validation.constraints.NotNull;
023
024/** User ID for GRSciColl contacts. */
025public class UserId implements Serializable {
026
027  private IdType type;
028  private String id;
029
030  public UserId() {}
031
032  public UserId(IdType type, String id) {
033    this.type = type;
034    this.id = id;
035  }
036
037  @NotNull
038  public IdType getType() {
039    return type;
040  }
041
042  public void setType(IdType type) {
043    this.type = type;
044  }
045
046  @NotNull
047  public String getId() {
048    return id;
049  }
050
051  public void setId(String id) {
052    this.id = id;
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    UserId userID = (UserId) o;
064    return type == userID.type && Objects.equals(id, userID.id);
065  }
066
067  @Override
068  public int hashCode() {
069    return Objects.hash(type, id);
070  }
071
072  @Override
073  public String toString() {
074    return new StringJoiner(", ", UserId.class.getSimpleName() + "[", "]")
075        .add("type=" + type)
076        .add("id='" + id + "'")
077        .toString();
078  }
079}