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