View Javadoc
1   package de.dlr.shepard.context.references.dataobject.entities;
2   
3   import de.dlr.shepard.common.util.Constants;
4   import de.dlr.shepard.common.util.HasId;
5   import de.dlr.shepard.context.collection.entities.Collection;
6   import de.dlr.shepard.context.references.basicreference.entities.BasicReference;
7   import java.util.Objects;
8   import lombok.Data;
9   import lombok.NoArgsConstructor;
10  import lombok.ToString;
11  import org.neo4j.ogm.annotation.NodeEntity;
12  import org.neo4j.ogm.annotation.Relationship;
13  
14  @NodeEntity
15  @Data
16  @NoArgsConstructor
17  public class CollectionReference extends BasicReference {
18  
19    @ToString.Exclude
20    @Relationship(type = Constants.POINTS_TO)
21    private Collection referencedCollection;
22  
23    private String relationship;
24  
25    /**
26     * For testing purposes only
27     *
28     * @param id identifies the entity
29     */
30    public CollectionReference(long id) {
31      super(id);
32    }
33  
34    @Override
35    public int hashCode() {
36      final int prime = 31;
37      int result = super.hashCode();
38      result = prime * result + Objects.hash(relationship);
39      result = prime * result + HasId.hashcodeHelper(referencedCollection);
40      return result;
41    }
42  
43    @Override
44    public boolean equals(Object obj) {
45      if (this == obj) return true;
46      if (!super.equals(obj)) return false;
47      if (!(obj instanceof CollectionReference)) return false;
48      CollectionReference other = (CollectionReference) obj;
49      return (
50        Objects.equals(relationship, other.relationship) &&
51        HasId.equalsHelper(referencedCollection, other.referencedCollection)
52      );
53    }
54  }