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.registry.eml;
015
016import org.gbif.api.model.registry.Contact;
017
018import javax.annotation.Nullable;
019import java.util.ArrayList;
020import java.util.LinkedList;
021import java.util.List;
022import java.util.Objects;
023import java.util.StringJoiner;
024
025/**
026 * A dedicated class for related projects. Unless {@link Project} it only has essential fields.
027 */
028@SuppressWarnings({"unused", "LombokSetterMayBeUsed", "LombokGetterMayBeUsed"})
029public class RelatedProject {
030
031  private String title;
032  private String identifier;
033  private List<Contact> contacts = new ArrayList<>();
034  private String abstract_;
035
036  public String getTitle() {
037    return title;
038  }
039
040  public void setTitle(String title) {
041    this.title = title;
042  }
043
044  @Nullable
045  public String getIdentifier() {
046    return identifier;
047  }
048
049  public void setIdentifier(String identifier) {
050    this.identifier = identifier;
051  }
052
053  public List<Contact> getContacts() {
054    return contacts;
055  }
056
057  public void setContacts(List<Contact> contacts) {
058    this.contacts = contacts;
059  }
060
061  public void addContact(Contact contact) {
062    if (contacts == null) {
063      contacts = new LinkedList<>();
064    }
065    contacts.add(contact);
066  }
067
068  @Nullable
069  public String getAbstract() {
070    return abstract_;
071  }
072
073  public void setAbstract(String abstract_) {
074    this.abstract_ = abstract_;
075  }
076
077  @Override
078  public boolean equals(Object o) {
079    if (this == o) return true;
080    if (o == null || getClass() != o.getClass()) return false;
081    RelatedProject that = (RelatedProject) o;
082    return Objects.equals(title, that.title)
083        && Objects.equals(identifier, that.identifier)
084        && Objects.equals(abstract_, that.abstract_)
085        && Objects.equals(contacts, that.contacts);
086  }
087
088  @Override
089  public int hashCode() {
090    return Objects.hash(title, identifier, abstract_, contacts);
091  }
092
093  @Override
094  public String toString() {
095    return new StringJoiner(", ", RelatedProject.class.getSimpleName() + "[", "]")
096        .add("title='" + title + "'")
097        .add("identifier='" + identifier + "'")
098        .add("abstract_='" + abstract_ + "'")
099        .add("contacts=" + contacts)
100        .toString();
101  }
102}