1 package de.dlr.shepard.context.references.basicreference.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.DataObject;
6 import de.dlr.shepard.context.version.entities.VersionableEntity;
7 import lombok.Data;
8 import lombok.NoArgsConstructor;
9 import lombok.ToString;
10 import org.neo4j.ogm.annotation.NodeEntity;
11 import org.neo4j.ogm.annotation.Relationship;
12 import org.neo4j.ogm.annotation.Relationship.Direction;
13
14 @NodeEntity
15 @Data
16 @ToString(callSuper = true, onlyExplicitlyIncluded = true)
17 @NoArgsConstructor
18 public class BasicReference extends VersionableEntity {
19
20 @Relationship(type = Constants.HAS_REFERENCE, direction = Direction.INCOMING)
21 private DataObject dataObject;
22
23
24
25
26
27
28 public BasicReference(long id) {
29 super(id);
30 }
31
32
33
34
35
36
37 public String getType() {
38 return this.getClass().getSimpleName();
39 }
40
41 @Override
42 public int hashCode() {
43 final int prime = 31;
44 int result = super.hashCode();
45 result = prime * result + HasId.hashcodeHelper(dataObject);
46 return result;
47 }
48
49 @Override
50 public boolean equals(Object obj) {
51 if (this == obj) return true;
52 if (!super.equals(obj)) return false;
53 if (!(obj instanceof BasicReference)) return false;
54 BasicReference other = (BasicReference) obj;
55 return HasId.equalsHelper(dataObject, other.dataObject);
56 }
57 }