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.search.collections;
017
018import java.util.Objects;
019import java.util.StringJoiner;
020import java.util.UUID;
021
022/**
023 * A utility container for holding the key, code and name of an entity.
024 */
025public class KeyCodeNameResult {
026
027  private UUID key;
028  private String code;
029  private String name;
030
031  public KeyCodeNameResult() {
032
033  }
034
035  public KeyCodeNameResult(UUID key, String code, String name) {
036    this.key = key;
037    this.code = code;
038    this.name = name;
039  }
040
041  public UUID getKey() {
042    return key;
043  }
044
045  public void setKey(UUID key) {
046    this.key = key;
047  }
048
049  public String getCode() {
050    return code;
051  }
052
053  public void setCode(String code) {
054    this.code = code;
055  }
056
057  public String getName() {
058    return name;
059  }
060
061  public void setName(String name) {
062    this.name = name;
063  }
064
065  @Override
066  public boolean equals(Object o) {
067    if (this == o) return true;
068    if (o == null || getClass() != o.getClass()) return false;
069    KeyCodeNameResult that = (KeyCodeNameResult) o;
070    return Objects.equals(key, that.key) && Objects.equals(code, that.code) && Objects.equals(name, that.name);
071  }
072
073  @Override
074  public int hashCode() {
075    return Objects.hash(key, code, name);
076  }
077
078  @Override
079  public String toString() {
080    return new StringJoiner(", ", KeyCodeNameResult.class.getSimpleName() + "[", "]").add("key=" + key)
081      .add("code='" + code + "'")
082      .add("name='" + name + "'")
083      .toString();
084  }
085}