-
Notifications
You must be signed in to change notification settings - Fork 5
/
ThermalUnits.java
94 lines (84 loc) · 2.81 KB
/
ThermalUnits.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
/*
* © 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.ThermalHouseInput;
import edu.ie3.datamodel.models.input.thermal.ThermalStorageInput;
import edu.ie3.datamodel.models.input.thermal.ThermalUnitInput;
import java.util.*;
/**
* Container to group together all {@link ThermalUnitInput}s
*
* @param houses Available houses
* @param storages Available storage
*/
public record ThermalUnits(Set<ThermalHouseInput> houses, Set<ThermalStorageInput> storages)
implements InputContainer<ThermalUnitInput> {
public ThermalUnits(
Collection<ThermalHouseInput> houses, Collection<ThermalStorageInput> storages) {
this(new HashSet<>(houses), new HashSet<>(storages));
}
@Override
public List<ThermalUnitInput> allEntitiesAsList() {
List<ThermalUnitInput> ret = new ArrayList<>(houses.size() + storages.size());
ret.addAll(houses);
ret.addAll(storages);
return ret;
}
@Override
public ThermalUnitsCopyBuilder copy() {
return new ThermalUnitsCopyBuilder(this);
}
@Override
public String toString() {
return "ThermalUnits{" + "#houses=" + houses.size() + ", #storages=" + storages.size() + '}';
}
/**
* A builder pattern based approach to create copies of {@link ThermalUnits} containers with
* altered field values. For detailed field descriptions refer to java docs of {@link
* ThermalUnits}
*
* @version 3.1
* @since 14.02.23
*/
public static class ThermalUnitsCopyBuilder
implements InputContainerCopyBuilder<ThermalUnitInput> {
private Set<ThermalHouseInput> houses;
private Set<ThermalStorageInput> storages;
/**
* Constructor for {@link ThermalUnitsCopyBuilder}
*
* @param thermalUnits instance of {@link ThermalUnits}
*/
protected ThermalUnitsCopyBuilder(ThermalUnits thermalUnits) {
this.houses = thermalUnits.houses();
this.storages = thermalUnits.storages();
}
/**
* Method to alter {@link ThermalHouseInput}
*
* @param houses altered thermal houses
* @return this instance of {@link ThermalUnitsCopyBuilder}
*/
public ThermalUnitsCopyBuilder houses(Set<ThermalHouseInput> houses) {
this.houses = houses;
return this;
}
/**
* Method to alter {@link ThermalStorageInput}
*
* @param storages altered thermal storages
* @return this instance of {@link ThermalUnitsCopyBuilder}
*/
public ThermalUnitsCopyBuilder storages(Set<ThermalStorageInput> storages) {
this.storages = storages;
return this;
}
@Override
public ThermalUnits build() {
return new ThermalUnits(houses, storages);
}
}
}