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.ShepardFile;
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 FileReference extends BasicReference {
21
22 @Relationship(type = Constants.HAS_PAYLOAD)
23 private List<ShepardFile> files = new ArrayList<>();
24
25 @ToString.Exclude
26 @Relationship(type = Constants.IS_IN_CONTAINER)
27 private FileContainer fileContainer;
28
29
30
31
32
33
34 public FileReference(long id) {
35 super(id);
36 }
37
38 public void addFile(ShepardFile file) {
39 files.add(file);
40 }
41
42 @Override
43 public int hashCode() {
44 final int prime = 31;
45 int result = super.hashCode();
46 result = prime * result + Objects.hash(files);
47 result = prime * result + HasId.hashcodeHelper(fileContainer);
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 FileReference))
58 return false;
59 FileReference other = (FileReference) obj;
60 return HasId.equalsHelper(fileContainer, other.fileContainer) && Objects.equals(files, other.files);
61 }
62
63 }