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.occurrence;
015
016import java.util.Objects;
017import java.util.StringJoiner;
018
019/**
020 * Occurrence relations based on the dwc:ResourceRelationship model.
021 * See <a href="http://rs.tdwg.org/dwc/terms/ResourceRelationship">Darwin Core</a>.
022 */
023public class OccurrenceRelation {
024  private String id;  // resourceRelationshipID
025  private long occurrenceId;  // "from" resourceID
026  private long relatedOccurrenceId;  // "to" relatedResourceID
027  private String type;  // relationshipOfResource
028  private String accordingTo; // relationshipAccordingTo
029  private String establishedDate;  // relationshipEstablishedDate
030  private String remarks;  // relationshipRemarks
031
032  public String getId() {
033    return id;
034  }
035
036  public void setId(String id) {
037    this.id = id;
038  }
039
040  public long getOccurrenceId() {
041    return occurrenceId;
042  }
043
044  public void setOccurrenceId(long occurrenceId) {
045    this.occurrenceId = occurrenceId;
046  }
047
048  public long getRelatedOccurrenceId() {
049    return relatedOccurrenceId;
050  }
051
052  public void setRelatedOccurrenceId(long relatedOccurrenceId) {
053    this.relatedOccurrenceId = relatedOccurrenceId;
054  }
055
056  public String getType() {
057    return type;
058  }
059
060  public void setType(String type) {
061    this.type = type;
062  }
063
064  public String getAccordingTo() {
065    return accordingTo;
066  }
067
068  public void setAccordingTo(String accordingTo) {
069    this.accordingTo = accordingTo;
070  }
071
072  public String getEstablishedDate() {
073    return establishedDate;
074  }
075
076  public void setEstablishedDate(String establishedDate) {
077    this.establishedDate = establishedDate;
078  }
079
080  public String getRemarks() {
081    return remarks;
082  }
083
084  public void setRemarks(String remarks) {
085    this.remarks = remarks;
086  }
087
088  @Override
089  public boolean equals(Object o) {
090    if (this == o) {
091      return true;
092    }
093    if (o == null || getClass() != o.getClass()) {
094      return false;
095    }
096    OccurrenceRelation that = (OccurrenceRelation) o;
097    return occurrenceId == that.occurrenceId &&
098      relatedOccurrenceId == that.relatedOccurrenceId &&
099      Objects.equals(id, that.id) &&
100      Objects.equals(type, that.type) &&
101      Objects.equals(accordingTo, that.accordingTo) &&
102      Objects.equals(establishedDate, that.establishedDate) &&
103      Objects.equals(remarks, that.remarks);
104  }
105
106  @Override
107  public int hashCode() {
108    return Objects
109      .hash(id, occurrenceId, relatedOccurrenceId, type, accordingTo, establishedDate, remarks);
110  }
111
112  @Override
113  public String toString() {
114    return new StringJoiner(", ", OccurrenceRelation.class.getSimpleName() + "[", "]")
115      .add("id='" + id + "'")
116      .add("occurrenceId=" + occurrenceId)
117      .add("relatedOccurrenceId=" + relatedOccurrenceId)
118      .add("type='" + type + "'")
119      .add("accordingTo='" + accordingTo + "'")
120      .add("establishedDate='" + establishedDate + "'")
121      .add("remarks='" + remarks + "'")
122      .toString();
123  }
124}