-
Notifications
You must be signed in to change notification settings - Fork 5
/
SystemParticipantTypedEntityData.java
122 lines (112 loc) · 4.1 KB
/
SystemParticipantTypedEntityData.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
/*
* © 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.factory.input.participant;
import edu.ie3.datamodel.models.UniqueEntity;
import edu.ie3.datamodel.models.input.EmInput;
import edu.ie3.datamodel.models.input.NodeInput;
import edu.ie3.datamodel.models.input.OperatorInput;
import edu.ie3.datamodel.models.input.system.type.SystemParticipantTypeInput;
import java.util.Map;
import java.util.Objects;
/**
* Data used for those classes of {@link
* edu.ie3.datamodel.models.input.system.SystemParticipantInput} that need an instance of some type
* T of {@link SystemParticipantTypeInput} as well.
*
* @param <T> Subclass of {@link SystemParticipantTypeInput} that is required for the construction
* of the SystemParticipantInput
*/
public class SystemParticipantTypedEntityData<T extends SystemParticipantTypeInput>
extends SystemParticipantEntityData {
private final T typeInput;
/**
* Creates a new SystemParticipantEntityData object for an operated, always on system participant
* input that needs a type input as well
*
* @param fieldsToAttributes attribute map: field name to value
* @param entityClass class of the entity to be created with this data
* @param node input node
* @param em The energy management unit that is managing the system participant. Null, if the
* system participant is not managed.
* @param typeInput type input
*/
public SystemParticipantTypedEntityData(
Map<String, String> fieldsToAttributes,
Class<? extends UniqueEntity> entityClass,
NodeInput node,
EmInput em,
T typeInput) {
super(fieldsToAttributes, entityClass, node, em);
this.typeInput = typeInput;
}
/**
* Creates a new SystemParticipantEntityData object for an operable system participant input that
* needs a type input as well
*
* @param fieldsToAttributes attribute map: field name to value
* @param entityClass class of the entity to be created with this data
* @param operator operator input
* @param node input node
* @param em The energy management unit that is managing the system participant. Null, if the
* system participant is not managed.
* @param typeInput type input
*/
public SystemParticipantTypedEntityData(
Map<String, String> fieldsToAttributes,
Class<? extends UniqueEntity> entityClass,
OperatorInput operator,
NodeInput node,
EmInput em,
T typeInput) {
super(fieldsToAttributes, entityClass, operator, node, em);
this.typeInput = typeInput;
}
/**
* Creates a new SystemParticipantTypedEntityData object based on a given {@link
* SystemParticipantEntityData} object and given type input
*
* @param systemParticipantEntityData The system participant entity data object to use attributes
* of
* @param typeInput type input
*/
public SystemParticipantTypedEntityData(
SystemParticipantEntityData systemParticipantEntityData, T typeInput) {
super(systemParticipantEntityData, systemParticipantEntityData.getEm().orElse(null));
this.typeInput = typeInput;
}
public T getTypeInput() {
return typeInput;
}
@Override
public String toString() {
return "SystemParticipantTypedEntityData{"
+ "typeInput="
+ typeInput.getUuid()
+ ", em="
+ getEm().map(EmInput::toString).orElse("")
+ ", node="
+ getNode().getUuid()
+ ", operatorInput="
+ getOperatorInput().getUuid()
+ ", fieldsToValues="
+ getFieldsToValues()
+ ", targetClass="
+ getTargetClass()
+ '}';
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
if (!super.equals(o)) return false;
SystemParticipantTypedEntityData<?> that = (SystemParticipantTypedEntityData<?>) o;
return getTypeInput().equals(that.getTypeInput());
}
@Override
public int hashCode() {
return Objects.hash(super.hashCode(), getTypeInput());
}
}