View Javadoc
1   package de.dlr.shepard.neo4Core.entities;
2   
3   import org.neo4j.ogm.annotation.NodeEntity;
4   import org.neo4j.ogm.annotation.Relationship;
5   
6   import de.dlr.shepard.util.Constants;
7   import de.dlr.shepard.util.HasId;
8   import lombok.Data;
9   import lombok.NoArgsConstructor;
10  import lombok.ToString;
11  
12  @NodeEntity
13  @Data
14  @ToString(callSuper = true)
15  @NoArgsConstructor
16  public class BasicReference extends BasicEntity {
17  
18  	@ToString.Exclude
19  	@Relationship(type = Constants.HAS_REFERENCE, direction = Relationship.INCOMING)
20  	private DataObject dataObject;
21  
22  	/**
23  	 * For testing purposes only
24  	 *
25  	 * @param id identifies the entity
26  	 */
27  	public BasicReference(long id) {
28  		super(id);
29  	}
30  
31  	/**
32  	 * Returns the name of the implemented class
33  	 *
34  	 * @return the simple class name
35  	 */
36  	public String getType() {
37  		return this.getClass().getSimpleName();
38  	}
39  
40  	@Override
41  	public int hashCode() {
42  		final int prime = 31;
43  		int result = super.hashCode();
44  		result = prime * result + HasId.hashcodeHelper(dataObject);
45  		return result;
46  	}
47  
48  	@Override
49  	public boolean equals(Object obj) {
50  		if (this == obj)
51  			return true;
52  		if (!super.equals(obj))
53  			return false;
54  		if (!(obj instanceof BasicReference))
55  			return false;
56  		BasicReference other = (BasicReference) obj;
57  		return HasId.equalsHelper(dataObject, other.dataObject);
58  	}
59  }