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