Skip to content

Commit a089adb

Browse files
authored
Merge pull request #1269 from ie3-institute/mh/#1250-CopyBuilders-return-thisInstance
Copy builders return this instance
2 parents 7070586 + 3d1cf84 commit a089adb

36 files changed

+178
-139
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [Unreleased/Snapshot]
88

9+
### Added
10+
11+
### Fixed
12+
13+
### Changed
14+
- Replaced `return this` with `return thisInstance` in CopyBuilders [#1250](https://github.com/ie3-institute/PowerSystemDataModel/issues/1250)
15+
916
## [6.0.0] - 2025-02-27
1017

1118
### Added

src/main/java/edu/ie3/datamodel/models/input/EmInput.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ protected EmInputCopyBuilder(EmInput entity) {
119119

120120
public EmInputCopyBuilder controlStrategy(String controlStrategy) {
121121
this.controlStrategy = controlStrategy;
122-
return this;
122+
return thisInstance();
123123
}
124124

125125
public EmInputCopyBuilder parentEm(EmInput parentEm) {

src/main/java/edu/ie3/datamodel/models/input/MeasurementUnitInput.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -183,27 +183,27 @@ public MeasurementUnitInput build() {
183183

184184
public MeasurementUnitInputCopyBuilder node(NodeInput node) {
185185
this.node = node;
186-
return this;
186+
return thisInstance();
187187
}
188188

189189
public MeasurementUnitInputCopyBuilder vMag(boolean vMag) {
190190
this.vMag = vMag;
191-
return this;
191+
return thisInstance();
192192
}
193193

194194
public MeasurementUnitInputCopyBuilder vAng(boolean vAng) {
195195
this.vAng = vAng;
196-
return this;
196+
return thisInstance();
197197
}
198198

199199
public MeasurementUnitInputCopyBuilder p(boolean p) {
200200
this.p = p;
201-
return this;
201+
return thisInstance();
202202
}
203203

204204
public MeasurementUnitInputCopyBuilder q(boolean q) {
205205
this.q = q;
206-
return this;
206+
return thisInstance();
207207
}
208208

209209
@Override

src/main/java/edu/ie3/datamodel/models/input/NodeInput.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -203,27 +203,27 @@ public NodeInput build() {
203203

204204
public NodeInputCopyBuilder vTarget(ComparableQuantity<Dimensionless> vTarget) {
205205
this.vTarget = vTarget;
206-
return this;
206+
return thisInstance();
207207
}
208208

209209
public NodeInputCopyBuilder slack(boolean isSlack) {
210210
this.slack = isSlack;
211-
return this;
211+
return thisInstance();
212212
}
213213

214214
public NodeInputCopyBuilder geoPosition(Point geoPosition) {
215215
this.geoPosition = geoPosition;
216-
return this;
216+
return thisInstance();
217217
}
218218

219219
public NodeInputCopyBuilder voltLvl(VoltageLevel voltLvl) {
220220
this.voltLvl = voltLvl;
221-
return this;
221+
return thisInstance();
222222
}
223223

224224
public NodeInputCopyBuilder subnet(int subnet) {
225225
this.subnet = subnet;
226-
return this;
226+
return thisInstance();
227227
}
228228

229229
@Override

src/main/java/edu/ie3/datamodel/models/input/OperatorInput.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public OperatorInput build() {
7979

8080
public OperatorInputCopyBuilder id(String id) {
8181
this.id = id;
82-
return this;
82+
return thisInstance();
8383
}
8484

8585
@Override

src/main/java/edu/ie3/datamodel/models/input/connector/LineInput.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -205,22 +205,22 @@ public LineInput build() {
205205

206206
public LineInputCopyBuilder geoPosition(LineString geoPosition) {
207207
this.geoPosition = geoPosition;
208-
return this;
208+
return thisInstance();
209209
}
210210

211211
public LineInputCopyBuilder type(LineTypeInput type) {
212212
this.type = type;
213-
return this;
213+
return thisInstance();
214214
}
215215

216216
public LineInputCopyBuilder length(ComparableQuantity<Length> length) {
217217
this.length = length;
218-
return this;
218+
return thisInstance();
219219
}
220220

221221
public LineInputCopyBuilder olmCharacteristic(OlmCharacteristicInput olmCharacteristic) {
222222
this.olmCharacteristic = olmCharacteristic;
223-
return this;
223+
return thisInstance();
224224
}
225225

226226
@Override

src/main/java/edu/ie3/datamodel/models/input/connector/SwitchInput.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ public SwitchInput build() {
123123

124124
public SwitchInputCopyBuilder closed(boolean closed) {
125125
this.closed = closed;
126-
return this;
126+
return thisInstance();
127127
}
128128

129129
@Override

src/main/java/edu/ie3/datamodel/models/input/connector/Transformer2WInput.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ public Transformer2WInput build() {
161161

162162
public Transformer2WInputCopyBuilder type(Transformer2WTypeInput type) {
163163
this.type = type;
164-
return this;
164+
return thisInstance();
165165
}
166166

167167
@Override

src/main/java/edu/ie3/datamodel/models/input/connector/Transformer3WInput.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -328,17 +328,17 @@ public Transformer3WInput build() {
328328

329329
public Transformer3WInputCopyBuilder type(Transformer3WTypeInput type) {
330330
this.type = type;
331-
return this;
331+
return thisInstance();
332332
}
333333

334334
public Transformer3WInputCopyBuilder nodeC(NodeInput nodeC) {
335335
this.nodeC = nodeC;
336-
return this;
336+
return thisInstance();
337337
}
338338

339339
public Transformer3WInputCopyBuilder internalSlack(boolean internalNodeIsSlack) {
340340
this.internSlack = internalNodeIsSlack;
341-
return this;
341+
return thisInstance();
342342
}
343343

344344
@Override

src/main/java/edu/ie3/datamodel/models/input/container/GraphicElements.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,7 @@ public int hashCode() {
102102
* @version 3.1
103103
* @since 14.02.23
104104
*/
105-
public static class GraphicElementsCopyBuilder
106-
implements InputContainerCopyBuilder<GraphicInput> {
105+
public static class GraphicElementsCopyBuilder extends InputContainerCopyBuilder<GraphicInput> {
107106
private Set<NodeGraphicInput> nodeGraphics;
108107
private Set<LineGraphicInput> lineGraphics;
109108

@@ -125,7 +124,7 @@ protected GraphicElementsCopyBuilder(GraphicElements graphicElements) {
125124
*/
126125
public GraphicElementsCopyBuilder nodeGraphics(Set<NodeGraphicInput> nodeGraphics) {
127126
this.nodeGraphics = nodeGraphics;
128-
return this;
127+
return thisInstance();
129128
}
130129

131130
/**
@@ -136,12 +135,17 @@ public GraphicElementsCopyBuilder nodeGraphics(Set<NodeGraphicInput> nodeGraphic
136135
*/
137136
public GraphicElementsCopyBuilder lineGraphics(Set<LineGraphicInput> lineGraphics) {
138137
this.lineGraphics = lineGraphics;
139-
return this;
138+
return thisInstance();
140139
}
141140

142141
@Override
143142
public GraphicElements build() {
144143
return new GraphicElements(nodeGraphics, lineGraphics);
145144
}
145+
146+
@Override
147+
protected GraphicElementsCopyBuilder thisInstance() {
148+
return this;
149+
}
146150
}
147151
}

0 commit comments

Comments
 (0)