View Javadoc
1   package de.dlr.shepard.neo4Core.entities;
2   
3   import java.util.Objects;
4   
5   import org.neo4j.ogm.annotation.GeneratedValue;
6   import org.neo4j.ogm.annotation.Id;
7   import org.neo4j.ogm.annotation.NodeEntity;
8   import org.neo4j.ogm.annotation.Relationship;
9   
10  import de.dlr.shepard.util.Constants;
11  import de.dlr.shepard.util.HasId;
12  import lombok.Data;
13  import lombok.NoArgsConstructor;
14  import lombok.ToString;
15  
16  @NodeEntity
17  @Data
18  @NoArgsConstructor
19  public class SemanticAnnotation implements HasId {
20  
21  	@Id
22  	@GeneratedValue
23  	private Long id;
24  
25  	private String name;
26  
27  	private String propertyIRI;
28  
29  	private String valueIRI;
30  
31  	@ToString.Exclude
32  	@Relationship(type = Constants.PROPERTY_REPOSITORY)
33  	private SemanticRepository propertyRepository;
34  
35  	@ToString.Exclude
36  	@Relationship(type = Constants.VALUE_REPOSITORY)
37  	private SemanticRepository valueRepository;
38  
39  	/**
40  	 * For testing purposes only
41  	 *
42  	 * @param id identifies the entity
43  	 */
44  	public SemanticAnnotation(long id) {
45  		this.id = id;
46  	}
47  
48  	@Override
49  	public int hashCode() {
50  		final int prime = 31;
51  		var result = Objects.hash(id, name, propertyIRI, valueIRI);
52  		result = prime * result + HasId.hashcodeHelper(propertyRepository);
53  		result = prime * result + HasId.hashcodeHelper(valueRepository);
54  		return result;
55  	}
56  
57  	@Override
58  	public boolean equals(Object obj) {
59  		if (this == obj)
60  			return true;
61  		if (obj == null)
62  			return false;
63  		if (!(obj instanceof SemanticAnnotation))
64  			return false;
65  		SemanticAnnotation other = (SemanticAnnotation) obj;
66  		return Objects.equals(id, other.id) && Objects.equals(name, other.name)
67  				&& Objects.equals(propertyIRI, other.propertyIRI) && Objects.equals(valueIRI, other.valueIRI)
68  				&& HasId.equalsHelper(propertyRepository, other.propertyRepository)
69  				&& HasId.equalsHelper(valueRepository, other.valueRepository);
70  	}
71  
72  	@Override
73  	public String getUniqueId() {
74  		return id.toString();
75  	}
76  }