-
Notifications
You must be signed in to change notification settings - Fork 5
/
GridContainer.java
203 lines (177 loc) · 5.9 KB
/
GridContainer.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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
/*
* © 2021. TU Dortmund University,
* Institute of Energy Systems, Energy Efficiency and Energy Economics,
* Research group Distribution grid planning and operation
*/
package edu.ie3.datamodel.models.input.container;
import edu.ie3.datamodel.models.input.InputEntity;
import java.util.*;
public abstract class GridContainer implements InputContainer<InputEntity> {
/** Name of this grid */
protected final String gridName;
/** Accumulated raw grid elements (lines, nodes, transformers, switches) */
protected final RawGridElements rawGrid;
/** Accumulated system participant elements */
protected final SystemParticipants systemParticipants;
/** Accumulated energy management units */
protected final EnergyManagementUnits emUnits;
/** Accumulated graphic data entities (node graphics, line graphics) */
protected final GraphicElements graphics;
protected GridContainer(
String gridName,
RawGridElements rawGrid,
SystemParticipants systemParticipants,
EnergyManagementUnits emUnits,
GraphicElements graphics) {
this.gridName = gridName;
this.rawGrid = rawGrid;
this.systemParticipants = systemParticipants;
this.emUnits = emUnits;
this.graphics = graphics;
}
@Override
public List<InputEntity> allEntitiesAsList() {
List<InputEntity> allEntities = new LinkedList<>();
allEntities.addAll(rawGrid.allEntitiesAsList());
allEntities.addAll(systemParticipants.allEntitiesAsList());
allEntities.addAll(emUnits.allEntitiesAsList());
allEntities.addAll(graphics.allEntitiesAsList());
return Collections.unmodifiableList(allEntities);
}
/**
* @return true, as we are positive people and believe in what we do. Just kidding. Checks are
* made during initialisation.
*/
public String getGridName() {
return gridName;
}
public RawGridElements getRawGrid() {
return rawGrid;
}
public SystemParticipants getSystemParticipants() {
return systemParticipants;
}
public EnergyManagementUnits getEmUnits() {
return emUnits;
}
public GraphicElements getGraphics() {
return graphics;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof GridContainer that)) return false;
return gridName.equals(that.gridName)
&& rawGrid.equals(that.rawGrid)
&& systemParticipants.equals(that.systemParticipants)
&& emUnits.equals(that.emUnits)
&& graphics.equals(that.graphics);
}
@Override
public int hashCode() {
return Objects.hash(gridName, rawGrid, systemParticipants, emUnits, graphics);
}
@Override
public String toString() {
return "GridContainer{" + "gridName='" + gridName + '\'' + '}';
}
/**
* Abstract class for all builder that build child containers of abstract class {@link
* GridContainer}
*
* @version 3.1
* @since 14.02.23
*/
protected abstract static class GridContainerCopyBuilder<B extends GridContainerCopyBuilder<B>>
implements InputContainerCopyBuilder<InputEntity> {
private String gridName;
private RawGridElements rawGrid;
private SystemParticipants systemParticipants;
private EnergyManagementUnits emUnits;
private GraphicElements graphics;
/**
* Constructor for {@link GridContainerCopyBuilder}.
*
* @param gridContainer instance of {@link GridContainerCopyBuilder}
*/
protected GridContainerCopyBuilder(GridContainer gridContainer) {
this.gridName = gridContainer.getGridName();
this.rawGrid = gridContainer.getRawGrid();
this.systemParticipants = gridContainer.getSystemParticipants();
this.emUnits = gridContainer.getEmUnits();
this.graphics = gridContainer.getGraphics();
}
/** Returns grid name */
protected String getGridName() {
return gridName;
}
/** Returns {@link RawGridElements}. */
protected RawGridElements getRawGrid() {
return rawGrid;
}
/** Returns {@link SystemParticipants} */
protected SystemParticipants getSystemParticipants() {
return systemParticipants;
}
/** Returns {@link EnergyManagementUnits} */
public EnergyManagementUnits getEmUnits() {
return emUnits;
}
/** Returns {@link GraphicElements} */
protected GraphicElements getGraphics() {
return graphics;
}
/**
* Method to alter the grid name.
*
* @param gridName altered grid name
* @return this instance of {@link GridContainerCopyBuilder}
*/
public B gridName(String gridName) {
this.gridName = gridName;
return thisInstance();
}
/**
* Method to alter the {@link RawGridElements}
*
* @param rawGrid altered raw grid
* @return this instance of {@link GridContainerCopyBuilder}
*/
public B rawGrid(RawGridElements rawGrid) {
this.rawGrid = rawGrid;
return thisInstance();
}
/**
* Method to alter the {@link SystemParticipants}.
*
* @param systemParticipants altered systemParticipants
* @return this instance of {@link GridContainerCopyBuilder}
*/
public B systemParticipants(SystemParticipants systemParticipants) {
this.systemParticipants = systemParticipants;
return thisInstance();
}
/**
* Method to alter the {@link EnergyManagementUnits}s.
*
* @param emUnits altered em units
* @return this instance of {@link GridContainerCopyBuilder}
*/
public B emUnits(EnergyManagementUnits emUnits) {
this.emUnits = emUnits;
return thisInstance();
}
/**
* Method to alter the {@link GraphicElements}.
*
* @param graphics altered graphics
* @return this instance of {@link GridContainerCopyBuilder}
*/
public B graphics(GraphicElements graphics) {
this.graphics = graphics;
return thisInstance();
}
/** Returns the current instance of builder with the correct subclass type */
protected abstract B thisInstance();
}
}