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