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.v2;
017
018import org.gbif.api.vocabulary.Rank;
019
020import java.util.Objects;
021
022/**
023 *
024 */
025public class RankedName {
026  private int key;
027  private String name;
028  private Rank rank;
029
030  public RankedName() {
031  }
032
033  public RankedName(int key, String name, Rank rank) {
034    this.key = key;
035    this.name = name;
036    this.rank = rank;
037  }
038
039  public int getKey() {
040    return key;
041  }
042
043  public void setKey(int key) {
044    this.key = key;
045  }
046
047  public String getName() {
048    return name;
049  }
050
051  public void setName(String name) {
052    this.name = name;
053  }
054
055  public Rank getRank() {
056    return rank;
057  }
058
059  public void setRank(Rank rank) {
060    this.rank = rank;
061  }
062
063  @Override
064  public boolean equals(Object o) {
065    if (this == o) return true;
066    if (o == null || getClass() != o.getClass()) return false;
067    RankedName u = (RankedName) o;
068    return key == u.key &&
069        Objects.equals(name, u.name) &&
070        rank == u.rank;
071  }
072
073  @Override
074  public int hashCode() {
075    return Objects.hash(key, name, rank);
076  }
077
078  @Override
079  public String toString() {
080    return new StringBuilder()
081        .append(name)
082        .append(" [")
083        .append(key)
084        .append(',')
085        .append(rank)
086        .append(']')
087        .toString();
088  }
089}