001package org.gbif.api.model.occurrence;
002
003import com.google.common.base.Objects;
004
005/**
006 * Occurrence relations based on the dwc:ResourceRelationship model.
007 * See <a href="http://darwincore.googlecode.com/svn/trunk/terms/index.htm#relindex">Darwin Core</a>.
008 */
009public class OccurrenceRelation {
010  private String id;  // resourceRelationshipID
011  private int occurrenceId;  // "from" resourceID
012  private int relatedOccurrenceId;  // "to" relatedResourceID
013  private String type;  // relationshipOfResource
014  private String accordingTo; // relationshipAccordingTo
015  private String establishedDate;  // relationshipEstablishedDate
016  private String remarks;  // relationshipRemarks
017
018  public String getId() {
019    return id;
020  }
021
022  public void setId(String id) {
023    this.id = id;
024  }
025
026  public int getOccurrenceId() {
027    return occurrenceId;
028  }
029
030  public void setOccurrenceId(int occurrenceId) {
031    this.occurrenceId = occurrenceId;
032  }
033
034  public int getRelatedOccurrenceId() {
035    return relatedOccurrenceId;
036  }
037
038  public void setRelatedOccurrenceId(int relatedOccurrenceId) {
039    this.relatedOccurrenceId = relatedOccurrenceId;
040  }
041
042  public String getType() {
043    return type;
044  }
045
046  public void setType(String type) {
047    this.type = type;
048  }
049
050  public String getAccordingTo() {
051    return accordingTo;
052  }
053
054  public void setAccordingTo(String accordingTo) {
055    this.accordingTo = accordingTo;
056  }
057
058  public String getEstablishedDate() {
059    return establishedDate;
060  }
061
062  public void setEstablishedDate(String establishedDate) {
063    this.establishedDate = establishedDate;
064  }
065
066  public String getRemarks() {
067    return remarks;
068  }
069
070  public void setRemarks(String remarks) {
071    this.remarks = remarks;
072  }
073
074  @Override
075  public int hashCode() {
076    return Objects.hashCode(id, occurrenceId, relatedOccurrenceId, type, accordingTo, establishedDate, remarks);
077  }
078
079  @Override
080  public boolean equals(Object obj) {
081    if (this == obj) {
082      return true;
083    }
084    if (!(obj instanceof OccurrenceRelation)) {
085      return false;
086    }
087    OccurrenceRelation that = (OccurrenceRelation) obj;
088    return Objects.equal(this.id, that.id)
089        && Objects.equal(this.occurrenceId, that.occurrenceId)
090        && Objects.equal(this.relatedOccurrenceId, that.relatedOccurrenceId)
091        && Objects.equal(this.type, that.type)
092        && Objects.equal(this.accordingTo, that.accordingTo)
093        && Objects.equal(this.establishedDate, that.establishedDate)
094        && Objects.equal(this.remarks, that.remarks);
095  }
096
097  @Override
098  public String toString() {
099    return Objects.toStringHelper(this)
100      .add("id", id)
101      .add("occurrenceId", occurrenceId)
102      .add("relatedOccurrenceId", relatedOccurrenceId)
103      .add("type", type)
104      .add("accordingTo", accordingTo)
105      .add("establishedDate", establishedDate)
106      .add("remarks", remarks)
107      .toString();
108  }
109}