1 package de.dlr.shepard.neo4Core.entities;
2
3 import java.util.ArrayList;
4 import java.util.List;
5 import java.util.Objects;
6
7 import org.neo4j.ogm.annotation.NodeEntity;
8 import org.neo4j.ogm.annotation.Relationship;
9
10 import de.dlr.shepard.mongoDB.StructuredData;
11 import de.dlr.shepard.util.Constants;
12 import de.dlr.shepard.util.HasId;
13 import lombok.Data;
14 import lombok.NoArgsConstructor;
15 import lombok.ToString;
16
17 @NodeEntity
18 @Data
19 @NoArgsConstructor
20 public class StructuredDataReference extends BasicReference {
21
22 @Relationship(type = Constants.HAS_PAYLOAD)
23 private List<StructuredData> structuredDatas = new ArrayList<>();
24
25 @ToString.Exclude
26 @Relationship(type = Constants.IS_IN_CONTAINER)
27 private StructuredDataContainer structuredDataContainer;
28
29
30
31
32
33
34 public StructuredDataReference(long id) {
35 super(id);
36 }
37
38 public void addStructuredData(StructuredData structuredData) {
39 structuredDatas.add(structuredData);
40 }
41
42 @Override
43 public int hashCode() {
44 final int prime = 31;
45 int result = super.hashCode();
46 result = prime * result + Objects.hash(structuredDatas);
47 result = prime * result + HasId.hashcodeHelper(structuredDataContainer);
48 return result;
49 }
50
51 @Override
52 public boolean equals(Object obj) {
53 if (this == obj)
54 return true;
55 if (!super.equals(obj))
56 return false;
57 if (!(obj instanceof StructuredDataReference))
58 return false;
59 StructuredDataReference other = (StructuredDataReference) obj;
60 return HasId.equalsHelper(structuredDataContainer, other.structuredDataContainer)
61 && Objects.equals(structuredDatas, other.structuredDatas);
62 }
63
64 }