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.collections.lookup;
017
018import java.net.URI;
019import java.util.Objects;
020import java.util.StringJoiner;
021import java.util.UUID;
022
023public abstract class BaseEntityMatched implements EntityMatched {
024
025  private UUID key;
026  private URI selfLink;
027  private String name;
028  private String code;
029  private boolean active;
030
031  @Override
032  public UUID getKey() {
033    return key;
034  }
035
036  public void setKey(UUID key) {
037    this.key = key;
038  }
039
040  @Override
041  public URI getSelfLink() {
042    return selfLink;
043  }
044
045  public void setSelfLink(URI selfLink) {
046    this.selfLink = selfLink;
047  }
048
049  @Override
050  public String getName() {
051    return name;
052  }
053
054  public void setName(String name) {
055    this.name = name;
056  }
057
058  @Override
059  public String getCode() {
060    return code;
061  }
062
063  public void setCode(String code) {
064    this.code = code;
065  }
066
067  @Override
068  public boolean isActive() {
069    return active;
070  }
071
072  public void setActive(boolean active) {
073    this.active = active;
074  }
075
076  @Override
077  public boolean equals(Object o) {
078    if (this == o) {
079      return true;
080    }
081    if (o == null || getClass() != o.getClass()) {
082      return false;
083    }
084    BaseEntityMatched that = (BaseEntityMatched) o;
085    return Objects.equals(key, that.key)
086        && Objects.equals(selfLink, that.selfLink)
087        && Objects.equals(name, that.name)
088        && Objects.equals(code, that.code)
089        && Objects.equals(active, that.active);
090  }
091
092  @Override
093  public int hashCode() {
094    return Objects.hash(key, selfLink, name, code, active);
095  }
096
097  @Override
098  public String toString() {
099    return new StringJoiner(", ", BaseEntityMatched.class.getSimpleName() + "[", "]")
100        .add("key=" + key)
101        .add("selfLink=" + selfLink)
102        .add("name='" + name + "'")
103        .add("code='" + code + "'")
104        .add("active='" + active + "'")
105        .toString();
106  }
107}