-
Notifications
You must be signed in to change notification settings - Fork 5
/
ConnectorInput.java
177 lines (154 loc) · 4.81 KB
/
ConnectorInput.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
/*
* © 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.connector;
import edu.ie3.datamodel.io.extractor.HasNodes;
import edu.ie3.datamodel.models.OperationTime;
import edu.ie3.datamodel.models.input.AssetInput;
import edu.ie3.datamodel.models.input.NodeInput;
import edu.ie3.datamodel.models.input.OperatorInput;
import java.util.*;
/** Describes an asset that connects two {@link NodeInput}s */
public abstract class ConnectorInput extends AssetInput implements HasNodes {
/** Grid node at one side of the connector */
private final NodeInput nodeA;
/** Grid node at the other side of the connector */
private final NodeInput nodeB;
/** Amount of parallelDevices */
private final int parallelDevices;
/**
* Constructor for an operated connector
*
* @param uuid of the input entity
* @param id of the asset
* @param operator of the asset
* @param operationTime Time for which the entity is operated
* @param nodeA Grid node at one side of the connector
* @param nodeB Grid node at the other side of the connector
* @param parallelDevices overall amount of parallel devices to automatically construct (e.g.
* parallelDevices = 2 will build a total of two entities using the specified parameters)
*/
protected ConnectorInput(
UUID uuid,
String id,
OperatorInput operator,
OperationTime operationTime,
NodeInput nodeA,
NodeInput nodeB,
int parallelDevices) {
super(uuid, id, operator, operationTime);
this.nodeA = nodeA;
this.nodeB = nodeB;
this.parallelDevices = parallelDevices;
}
/**
* Constructor for an operated, always on connector
*
* @param uuid of the input entity
* @param id of the asset
* @param nodeA Grid node at one side of the connector
* @param nodeB Grid node at the other side of the connector
* @param parallelDevices overall amount of parallel devices to automatically construct (e.g.
* parallelDevices = 2 will build a total of two entities using the specified parameters)
*/
protected ConnectorInput(
UUID uuid, String id, NodeInput nodeA, NodeInput nodeB, int parallelDevices) {
super(uuid, id);
this.nodeA = nodeA;
this.nodeB = nodeB;
this.parallelDevices = parallelDevices;
}
public NodeInput getNodeA() {
return nodeA;
}
public NodeInput getNodeB() {
return nodeB;
}
@Override
public abstract ConnectorInputCopyBuilder<?> copy();
@Override
public List<NodeInput> allNodes() {
return List.of(getNodeA(), getNodeB());
}
public int getParallelDevices() {
return parallelDevices;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof ConnectorInput that)) return false;
if (!super.equals(o)) return false;
return parallelDevices == that.parallelDevices
&& nodeA.equals(that.nodeA)
&& nodeB.equals(that.nodeB);
}
@Override
public int hashCode() {
return Objects.hash(super.hashCode(), nodeA, nodeB, parallelDevices);
}
@Override
public String toString() {
return "ConnectorInput{"
+ "uuid="
+ getUuid()
+ ", id="
+ getId()
+ ", operator="
+ getOperator().getUuid()
+ ", operationTime="
+ getOperationTime()
+ ", nodeA="
+ nodeA.getUuid()
+ ", nodeB="
+ nodeB.getUuid()
+ ", noOfParallelDevices="
+ parallelDevices
+ '}';
}
/**
* Abstract class for all builder that build child entities of abstract class {@link
* ConnectorInput}
*
* @version 0.1
* @since 05.06.20
*/
public abstract static class ConnectorInputCopyBuilder<B extends ConnectorInputCopyBuilder<B>>
extends AssetInputCopyBuilder<B> {
private NodeInput nodeA;
private NodeInput nodeB;
private int parallelDevices;
protected ConnectorInputCopyBuilder(ConnectorInput entity) {
super(entity);
this.nodeA = entity.getNodeA();
this.nodeB = entity.getNodeB();
this.parallelDevices = entity.getParallelDevices();
}
public B nodeA(NodeInput nodeA) {
this.nodeA = nodeA;
return thisInstance();
}
public B nodeB(NodeInput nodeB) {
this.nodeB = nodeB;
return thisInstance();
}
public B parallelDevices(int parallelDevices) {
this.parallelDevices = parallelDevices;
return thisInstance();
}
protected NodeInput getNodeA() {
return nodeA;
}
protected NodeInput getNodeB() {
return nodeB;
}
protected int getParallelDevices() {
return parallelDevices;
}
@Override
public abstract ConnectorInput build();
@Override
protected abstract B thisInstance();
}
}