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, onlyExplicitlyIncluded = true)
15  @NoArgsConstructor
16  public class BasicReference extends VersionableEntity {
17  
18  	@Relationship(type = Constants.HAS_REFERENCE, direction = Relationship.INCOMING)
19  	private DataObject dataObject;
20  
21  	/**
22  	 * For testing purposes only
23  	 *
24  	 * @param id identifies the entity
25  	 */
26  	public BasicReference(long id) {
27  		super(id);
28  	}
29  
30  	/**
31  	 * Returns the name of the implemented class
32  	 *
33  	 * @return the simple class name
34  	 */
35  	public String getType() {
36  		return this.getClass().getSimpleName();
37  	}
38  
39  	@Override
40  	public int hashCode() {
41  		final int prime = 31;
42  		int result = super.hashCode();
43  		result = prime * result + HasId.hashcodeHelper(dataObject);
44  		return result;
45  	}
46  
47  	@Override
48  	public boolean equals(Object obj) {
49  		if (this == obj)
50  			return true;
51  		if (!super.equals(obj))
52  			return false;
53  		if (!(obj instanceof BasicReference))
54  			return false;
55  		BasicReference other = (BasicReference) obj;
56  		return HasId.equalsHelper(dataObject, other.dataObject);
57  	}
58  }