-
Notifications
You must be signed in to change notification settings - Fork 5
/
TimeSeriesMappingSource.java
88 lines (75 loc) · 2.4 KB
/
TimeSeriesMappingSource.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/*
* © 2021. TU Dortmund University,
* Institute of Energy Systems, Energy Efficiency and Energy Economics,
* Research group Distribution grid planning and operation
*/
package edu.ie3.datamodel.io.source;
import edu.ie3.datamodel.io.factory.timeseries.TimeSeriesMappingFactory;
import edu.ie3.datamodel.models.input.InputEntity;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.UUID;
/**
* This interface describes basic function to handle mapping between models and their respective
* time series
*/
public abstract class TimeSeriesMappingSource implements DataSource {
protected final TimeSeriesMappingFactory mappingFactory;
public TimeSeriesMappingSource() {
this.mappingFactory = new TimeSeriesMappingFactory();
}
/**
* Get a mapping from model {@link UUID} to the time series {@link UUID}
*
* @return That mapping
*/
public abstract Map<UUID, UUID> getMapping();
/**
* Get a time series identifier to a given model identifier
*
* @param modelIdentifier Identifier of the model
* @return An {@link Optional} to the time series identifier
*/
public Optional<UUID> getTimeSeriesUuid(UUID modelIdentifier) {
return Optional.ofNullable(getMapping().get(modelIdentifier));
}
/** Class to represent one entry within the participant to time series mapping */
public static class MappingEntry extends InputEntity {
private final UUID participant;
private final UUID timeSeries;
public MappingEntry(UUID uuid, UUID participant, UUID timeSeries) {
super(uuid);
this.participant = participant;
this.timeSeries = timeSeries;
}
public UUID getParticipant() {
return participant;
}
public UUID getTimeSeries() {
return timeSeries;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof MappingEntry that)) return false;
if (!super.equals(o)) return false;
return participant.equals(that.participant) && timeSeries.equals(that.timeSeries);
}
@Override
public int hashCode() {
return Objects.hash(super.hashCode(), participant, timeSeries);
}
@Override
public String toString() {
return "MappingEntry{"
+ "uuid="
+ getUuid()
+ ", participant="
+ participant
+ ", timeSeries="
+ timeSeries
+ '}';
}
}
}