View Javadoc
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.influxDB.Timeseries;
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 TimeseriesReference extends BasicReference {
21  
22  	private long start;
23  
24  	private long end;
25  
26  	@Relationship(type = Constants.HAS_PAYLOAD)
27  	private List<Timeseries> timeseries = new ArrayList<>();
28  
29  	@ToString.Exclude
30  	@Relationship(type = Constants.IS_IN_CONTAINER)
31  	private TimeseriesContainer timeseriesContainer;
32  
33  	/**
34  	 * For testing purposes only
35  	 *
36  	 * @param id identifies the entity
37  	 */
38  	public TimeseriesReference(long id) {
39  		super(id);
40  	}
41  
42  	public void addTimeseries(Timeseries timeseries) {
43  		this.timeseries.add(timeseries);
44  	}
45  
46  	@Override
47  	public int hashCode() {
48  		final int prime = 31;
49  		int result = super.hashCode();
50  		result = prime * result + Objects.hash(end, start, timeseries);
51  		result = prime * result + HasId.hashcodeHelper(timeseriesContainer);
52  		return result;
53  	}
54  
55  	@Override
56  	public boolean equals(Object obj) {
57  		if (this == obj)
58  			return true;
59  		if (!super.equals(obj))
60  			return false;
61  		if (!(obj instanceof TimeseriesReference))
62  			return false;
63  		TimeseriesReference other = (TimeseriesReference) obj;
64  		return end == other.end && start == other.start && Objects.equals(timeseries, other.timeseries)
65  				&& HasId.equalsHelper(timeseriesContainer, other.timeseriesContainer);
66  	}
67  
68  }