1 package de.dlr.shepard.neo4Core.entities;
2
3 import de.dlr.shepard.mongoDB.ShepardFile;
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 FileReference extends BasicReference {
19
20 @Relationship(type = Constants.HAS_PAYLOAD)
21 private List<ShepardFile> files = new ArrayList<>();
22
23 @ToString.Exclude
24 @Relationship(type = Constants.IS_IN_CONTAINER)
25 private FileContainer fileContainer;
26
27
28
29
30
31
32 public FileReference(long id) {
33 super(id);
34 }
35
36 public void addFile(ShepardFile file) {
37 files.add(file);
38 }
39
40 @Override
41 public int hashCode() {
42 final int prime = 31;
43 int result = super.hashCode();
44 result = prime * result + Objects.hash(files);
45 result = prime * result + HasId.hashcodeHelper(fileContainer);
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 FileReference)) return false;
54 FileReference other = (FileReference) obj;
55 return HasId.equalsHelper(fileContainer, other.fileContainer) && Objects.equals(files, other.files);
56 }
57 }