Skip to content
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased/Snapshot]
- Replaced `return this` with `return thisInstance` in CopyBuilders [#1250](https://github.com/ie3-institute/PowerSystemDataModel/issues/1250)

## [6.0.0] - 2025-02-27

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/edu/ie3/datamodel/models/input/EmInput.java
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ protected EmInputCopyBuilder(EmInput entity) {

public EmInputCopyBuilder controlStrategy(String controlStrategy) {
this.controlStrategy = controlStrategy;
return this;
return thisInstance();
}

public EmInputCopyBuilder parentEm(EmInput parentEm) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,27 +183,27 @@ public MeasurementUnitInput build() {

public MeasurementUnitInputCopyBuilder node(NodeInput node) {
this.node = node;
return this;
return thisInstance();
}

public MeasurementUnitInputCopyBuilder vMag(boolean vMag) {
this.vMag = vMag;
return this;
return thisInstance();
}

public MeasurementUnitInputCopyBuilder vAng(boolean vAng) {
this.vAng = vAng;
return this;
return thisInstance();
}

public MeasurementUnitInputCopyBuilder p(boolean p) {
this.p = p;
return this;
return thisInstance();
}

public MeasurementUnitInputCopyBuilder q(boolean q) {
this.q = q;
return this;
return thisInstance();
}

@Override
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/edu/ie3/datamodel/models/input/NodeInput.java
Original file line number Diff line number Diff line change
Expand Up @@ -203,27 +203,27 @@ public NodeInput build() {

public NodeInputCopyBuilder vTarget(ComparableQuantity<Dimensionless> vTarget) {
this.vTarget = vTarget;
return this;
return thisInstance();
}

public NodeInputCopyBuilder slack(boolean isSlack) {
this.slack = isSlack;
return this;
return thisInstance();
}

public NodeInputCopyBuilder geoPosition(Point geoPosition) {
this.geoPosition = geoPosition;
return this;
return thisInstance();
}

public NodeInputCopyBuilder voltLvl(VoltageLevel voltLvl) {
this.voltLvl = voltLvl;
return this;
return thisInstance();
}

public NodeInputCopyBuilder subnet(int subnet) {
this.subnet = subnet;
return this;
return thisInstance();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public OperatorInput build() {

public OperatorInputCopyBuilder id(String id) {
this.id = id;
return this;
return thisInstance();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,22 +205,22 @@ public LineInput build() {

public LineInputCopyBuilder geoPosition(LineString geoPosition) {
this.geoPosition = geoPosition;
return this;
return thisInstance();
}

public LineInputCopyBuilder type(LineTypeInput type) {
this.type = type;
return this;
return thisInstance();
}

public LineInputCopyBuilder length(ComparableQuantity<Length> length) {
this.length = length;
return this;
return thisInstance();
}

public LineInputCopyBuilder olmCharacteristic(OlmCharacteristicInput olmCharacteristic) {
this.olmCharacteristic = olmCharacteristic;
return this;
return thisInstance();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public SwitchInput build() {

public SwitchInputCopyBuilder closed(boolean closed) {
this.closed = closed;
return this;
return thisInstance();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ public Transformer2WInput build() {

public Transformer2WInputCopyBuilder type(Transformer2WTypeInput type) {
this.type = type;
return this;
return thisInstance();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,17 +328,17 @@ public Transformer3WInput build() {

public Transformer3WInputCopyBuilder type(Transformer3WTypeInput type) {
this.type = type;
return this;
return thisInstance();
}

public Transformer3WInputCopyBuilder nodeC(NodeInput nodeC) {
this.nodeC = nodeC;
return this;
return thisInstance();
}

public Transformer3WInputCopyBuilder internalSlack(boolean internalNodeIsSlack) {
this.internSlack = internalNodeIsSlack;
return this;
return thisInstance();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,7 @@ public int hashCode() {
* @version 3.1
* @since 14.02.23
*/
public static class GraphicElementsCopyBuilder
implements InputContainerCopyBuilder<GraphicInput> {
public static class GraphicElementsCopyBuilder extends InputContainerCopyBuilder<GraphicInput> {
private Set<NodeGraphicInput> nodeGraphics;
private Set<LineGraphicInput> lineGraphics;

Expand All @@ -125,7 +124,7 @@ protected GraphicElementsCopyBuilder(GraphicElements graphicElements) {
*/
public GraphicElementsCopyBuilder nodeGraphics(Set<NodeGraphicInput> nodeGraphics) {
this.nodeGraphics = nodeGraphics;
return this;
return thisInstance();
}

/**
Expand All @@ -136,12 +135,17 @@ public GraphicElementsCopyBuilder nodeGraphics(Set<NodeGraphicInput> nodeGraphic
*/
public GraphicElementsCopyBuilder lineGraphics(Set<LineGraphicInput> lineGraphics) {
this.lineGraphics = lineGraphics;
return this;
return thisInstance();
}

@Override
public GraphicElements build() {
return new GraphicElements(nodeGraphics, lineGraphics);
}

@Override
protected GraphicElementsCopyBuilder thisInstance() {
return this;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public String toString() {
* @since 14.02.23
*/
protected abstract static class GridContainerCopyBuilder<B extends GridContainerCopyBuilder<B>>
implements InputContainerCopyBuilder<UniqueInputEntity> {
extends InputContainerCopyBuilder<UniqueInputEntity> {
private String gridName;
private RawGridElements rawGrid;
private SystemParticipants systemParticipants;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@ public interface InputContainer<T extends UniqueInputEntity> extends Serializabl
* @version 3.1
* @since 14.02.23
*/
interface InputContainerCopyBuilder<T extends UniqueInputEntity> {
abstract class InputContainerCopyBuilder<T extends UniqueInputEntity> {

/** Returns the altered {@link InputContainer} */
InputContainer<T> build() throws ValidationException;
public abstract InputContainer<T> build() throws ValidationException;

protected abstract InputContainerCopyBuilder<T> thisInstance();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ protected JointGridContainerCopyBuilder(JointGridContainer jointGridContainer) {
}

@Override
protected JointGridContainerCopyBuilder thisInstance() {
public JointGridContainerCopyBuilder thisInstance() {
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ public int hashCode() {
* @version 3.1
* @since 14.02.23
*/
public static class RawGridElementsCopyBuilder implements InputContainerCopyBuilder<AssetInput> {
public static class RawGridElementsCopyBuilder extends InputContainerCopyBuilder<AssetInput> {
private Set<NodeInput> nodes;
private Set<LineInput> lines;
private Set<Transformer2WInput> transformer2Ws;
Expand Down Expand Up @@ -217,7 +217,7 @@ protected RawGridElementsCopyBuilder(RawGridElements rawGridElements) {
*/
public RawGridElementsCopyBuilder nodes(Set<NodeInput> nodes) {
this.nodes = nodes;
return this;
return thisInstance();
}

/**
Expand All @@ -228,7 +228,7 @@ public RawGridElementsCopyBuilder nodes(Set<NodeInput> nodes) {
*/
public RawGridElementsCopyBuilder lines(Set<LineInput> lines) {
this.lines = lines;
return this;
return thisInstance();
}

/**
Expand All @@ -239,7 +239,7 @@ public RawGridElementsCopyBuilder lines(Set<LineInput> lines) {
*/
public RawGridElementsCopyBuilder transformers2Ws(Set<Transformer2WInput> transformer2Ws) {
this.transformer2Ws = transformer2Ws;
return this;
return thisInstance();
}

/**
Expand All @@ -250,7 +250,7 @@ public RawGridElementsCopyBuilder transformers2Ws(Set<Transformer2WInput> transf
*/
public RawGridElementsCopyBuilder transformer3Ws(Set<Transformer3WInput> transformer3Ws) {
this.transformer3Ws = transformer3Ws;
return this;
return thisInstance();
}

/**
Expand All @@ -261,7 +261,7 @@ public RawGridElementsCopyBuilder transformer3Ws(Set<Transformer3WInput> transfo
*/
public RawGridElementsCopyBuilder switches(Set<SwitchInput> switches) {
this.switches = switches;
return this;
return thisInstance();
}

/**
Expand All @@ -272,6 +272,11 @@ public RawGridElementsCopyBuilder switches(Set<SwitchInput> switches) {
*/
public RawGridElementsCopyBuilder measurementUnits(Set<MeasurementUnitInput> measurementUnits) {
this.measurementUnits = measurementUnits;
return thisInstance();
}

@Override
protected RawGridElementsCopyBuilder thisInstance() {
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public SubGridContainerCopyBuilder subnet(int subnet) {
}

@Override
protected SubGridContainerCopyBuilder thisInstance() {
public SubGridContainerCopyBuilder thisInstance() {
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ public int hashCode() {
* @since 14.02.23
*/
public static class SystemParticipantsCopyBuilder
implements InputContainerCopyBuilder<SystemParticipantInput> {
extends InputContainerCopyBuilder<SystemParticipantInput> {
private Set<BmInput> bmPlants;
private Set<ChpInput> chpPlants;
private Set<EvcsInput> evcs;
Expand Down Expand Up @@ -404,6 +404,11 @@ public SystemParticipantsCopyBuilder storages(Set<StorageInput> storages) {
*/
public SystemParticipantsCopyBuilder wecPlants(Set<WecInput> wecPlants) {
this.wecPlants = wecPlants;
return (SystemParticipantsCopyBuilder) thisInstance();
}

@Override
protected InputContainerCopyBuilder<SystemParticipantInput> thisInstance() {
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public String toString() {
* @version 3.1
* @since 14.02.23
*/
public static class ThermalGridCopyBuilder implements InputContainerCopyBuilder<ThermalInput> {
public static class ThermalGridCopyBuilder extends InputContainerCopyBuilder<ThermalInput> {
private ThermalBusInput bus;
private Set<ThermalHouseInput> houses;
private Set<ThermalStorageInput> heatStorages;
Expand All @@ -98,7 +98,7 @@ protected ThermalGridCopyBuilder(ThermalGrid thermalGrid) {
*/
public ThermalGridCopyBuilder bus(ThermalBusInput bus) {
this.bus = bus;
return this;
return thisInstance();
}

/**
Expand All @@ -109,7 +109,7 @@ public ThermalGridCopyBuilder bus(ThermalBusInput bus) {
*/
public ThermalGridCopyBuilder houses(Set<ThermalHouseInput> houses) {
this.houses = houses;
return this;
return thisInstance();
}

/**
Expand All @@ -120,7 +120,7 @@ public ThermalGridCopyBuilder houses(Set<ThermalHouseInput> houses) {
*/
public ThermalGridCopyBuilder heatStorages(Set<ThermalStorageInput> heatStorages) {
this.heatStorages = heatStorages;
return this;
return thisInstance();
}

/**
Expand All @@ -132,7 +132,7 @@ public ThermalGridCopyBuilder heatStorages(Set<ThermalStorageInput> heatStorages
public ThermalGridCopyBuilder domesticHotWaterStorages(
Set<ThermalStorageInput> domesticHotWaterStorages) {
this.domesticHotWaterStorages = domesticHotWaterStorages;
return this;
return thisInstance();
}

public ThermalGridCopyBuilder scale(Double factor) {
Expand All @@ -148,6 +148,11 @@ public ThermalGridCopyBuilder scale(Double factor) {
domesticHotWaterStorages.stream()
.map(storage -> storage.copy().scale(factor).build())
.collect(Collectors.toSet()));
return thisInstance();
}

@Override
protected ThermalGridCopyBuilder thisInstance() {
return this;
}

Expand Down
Loading