-
Notifications
You must be signed in to change notification settings - Fork 5
/
ThermalGrid.java
116 lines (105 loc) · 3.44 KB
/
ThermalGrid.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
/*
* © 2022. 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.thermal.ThermalBusInput;
import edu.ie3.datamodel.models.input.thermal.ThermalHouseInput;
import edu.ie3.datamodel.models.input.thermal.ThermalInput;
import edu.ie3.datamodel.models.input.thermal.ThermalStorageInput;
import java.util.*;
/**
* Container object to denote a fully connected thermal "grid". As there are currently no branch
* elements, a grid always only consists of one {@link ThermalBusInput} and all its connected {@link
* edu.ie3.datamodel.models.input.thermal.ThermalUnitInput}s
*/
public record ThermalGrid(
ThermalBusInput bus, Set<ThermalHouseInput> houses, Set<ThermalStorageInput> storages)
implements InputContainer<ThermalInput> {
public ThermalGrid(
ThermalBusInput bus,
Collection<ThermalHouseInput> houses,
Collection<ThermalStorageInput> storages) {
this(bus, new HashSet<>(houses), new HashSet<>(storages));
}
@Override
public List<ThermalInput> allEntitiesAsList() {
List<ThermalInput> ret = new ArrayList<>(houses.size() + storages.size() + 1);
ret.add(bus);
ret.addAll(houses);
ret.addAll(storages);
return ret;
}
@Override
public ThermalGridCopyBuilder copy() {
return new ThermalGridCopyBuilder(this);
}
@Override
public String toString() {
return "ThermalGrid{"
+ "bus="
+ bus
+ ", #houses="
+ houses.size()
+ ", #storages="
+ storages.size()
+ '}';
}
/**
* A builder pattern based approach to create copies of {@link ThermalGrid} containers with
* altered field values. For detailed field descriptions refer to java docs of {@link ThermalGrid}
*
* @version 3.1
* @since 14.02.23
*/
public static class ThermalGridCopyBuilder implements InputContainerCopyBuilder<ThermalGrid> {
private ThermalBusInput bus;
private Set<ThermalHouseInput> houses;
private Set<ThermalStorageInput> storages;
/**
* Constructor for {@link ThermalGridCopyBuilder}
*
* @param thermalGrid instance of {@link ThermalGrid}
*/
protected ThermalGridCopyBuilder(ThermalGrid thermalGrid) {
this.bus = thermalGrid.bus();
this.houses = thermalGrid.houses();
this.storages = thermalGrid.storages();
}
/**
* Method to alter {@link ThermalBusInput}
*
* @param bus altered thermal bus
* @return this instance of {@link ThermalGridCopyBuilder}
*/
public ThermalGridCopyBuilder bus(ThermalBusInput bus) {
this.bus = bus;
return this;
}
/**
* Method to alter {@link ThermalHouseInput}
*
* @param houses altered thermal houses
* @return this instance of {@link ThermalGridCopyBuilder}
*/
public ThermalGridCopyBuilder houses(Set<ThermalHouseInput> houses) {
this.houses = houses;
return this;
}
/**
* Method to alter {@link ThermalStorageInput}
*
* @param storages altered thermal storages
* @return this instance of {@link ThermalGridCopyBuilder}
*/
public ThermalGridCopyBuilder storages(Set<ThermalStorageInput> storages) {
this.storages = storages;
return this;
}
@Override
public ThermalGrid build() {
return new ThermalGrid(bus, houses, storages);
}
}
}