diff --git a/CHANGELOG.md b/CHANGELOG.md index bfbba7b2b..2348e5bb0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Implementing missing typical methods in `Try` [#970](https://github.com/ie3-institute/PowerSystemDataModel/issues/970) - Added log warning when using `SwitchInputs` with `parallelDevices` parameter [#840](https://github.com/ie3-institute/PowerSystemDataModel/issues/840) - Validation for `EvcsInput` [#1000](https://github.com/ie3-institute/PowerSystemDataModel/issues/1000) +- Scaling method in system participant copy builders [#1011](https://github.com/ie3-institute/PowerSystemDataModel/issues/1011) ### Fixed - Fixed Couchbase integration tests that randomly failed [#755](https://github.com/ie3-institute/PowerSystemDataModel/issues/755) diff --git a/docs/readthedocs/io/csvfiles.md b/docs/readthedocs/io/csvfiles.md index e022918ad..34111a343 100644 --- a/docs/readthedocs/io/csvfiles.md +++ b/docs/readthedocs/io/csvfiles.md @@ -58,7 +58,7 @@ You may extend / alter the naming with pre- or suffix by calling `new EntityPers Let's spend a few more words on the individual time series: Those files are meant to carry different types of content - one might give information about wholesale market prices, the other is a record of power values provided by a real system. -To be able to understand, what's inside of the file, the *columnScheme* part of the file name gives insight of it's +To be able to understand, what's inside of the file, the *columnScheme* part of the file name gives insight of its content. The following keys are supported until now: diff --git a/docs/readthedocs/models/input/participant/load.md b/docs/readthedocs/models/input/participant/load.md index 9c799c94e..c31f71549 100644 --- a/docs/readthedocs/models/input/participant/load.md +++ b/docs/readthedocs/models/input/participant/load.md @@ -77,7 +77,7 @@ If you found something, please contact us! ## Load Profiles -The {code}`LoadProfile` is an interface, that forces it's implementing classes to have a {code}`String` *key* +The {code}`LoadProfile` is an interface, that forces its implementing classes to have a {code}`String` *key* and being able to parse a {code}`String` to a {code}`LoadProfile`. Its only purpose is to give note, which load profile has to be used by the simulation. The actual profile has to be provided by the simulation itself. diff --git a/docs/readthedocs/models/models.md b/docs/readthedocs/models/models.md index b6043f8e1..dbb2b1ab8 100644 --- a/docs/readthedocs/models/models.md +++ b/docs/readthedocs/models/models.md @@ -18,22 +18,26 @@ We designed the models in a way, that does not allow for adaptions of the repres objects. Thereby you can be sure, that your models are *thread-safe* and no unwanted or unobserved changes are made. -**Copyable**
+**Clonability**
With the general design principle of immutability, entity modifications (e.g. updates of field values) can become hard and annoying. To avoid generating methods to update each field value, we provide an adapted version of the [Builder pattern](https://en.wikipedia.org/wiki/Builder_pattern/) to make entity modifications as easy as possible. -Each entity holds it's own copy builder class, which follows the same inheritance as the entity class itself. With a -call of `.copy()` on an entity instance a builder instance is returned, that allows for modification of fields and -can be terminated with `.build()` which will return an instance of the entity with modified field values as required. -For the moment, this pattern is only implemented for a small amount of `AssetInput` entities (all entities held by a -`GridContainer` except thermal units to be precise), but we plan to extend this capability to all input entities in the -future. +Each entity holds its own copy builder class, which follows the same inheritance as the entity class itself. With a +call of `.copy()` on an entity instance a builder instance is returned, which allows for modification of fields and +can be terminated with `.build()`. This will return an instance of the entity with modified field values as indicated. +For the moment, this pattern is only implemented for a limited set of entities, but we plan to extend this capability +to all input entities in the future. + +**Scaling entity properties**
+Using the copy builders (as described above) we provide a convenience method that helps with scaling system +participants and respective type inputs. Scaling entities tries to preserve proportions that are related to power. +This means that capacity, consumption etc. are scaled with the same factor as power. **Single Point of Truth**
Throughout all models you can be sure, that no information is given twice, reducing the possibility to have ambiguous information in your simulation set up. "Missing" information can be received through the grids relational information - e.g. if you intend to model a wind -energy converter in detail, you may find information of it's geographical location in the model of it's common +energy converter in detail, you may find information of its geographical location in the model of its common coupling point ([node](/models/input/grid/node)). **Harmonized Units System**
diff --git a/src/main/java/edu/ie3/datamodel/exceptions/NotImplementedException.java b/src/main/java/edu/ie3/datamodel/exceptions/NotImplementedException.java new file mode 100644 index 000000000..8cbc79b50 --- /dev/null +++ b/src/main/java/edu/ie3/datamodel/exceptions/NotImplementedException.java @@ -0,0 +1,12 @@ +/* + * © 2021. TU Dortmund University, + * Institute of Energy Systems, Energy Efficiency and Energy Economics, + * Research group Distribution grid planning and operation +*/ +package edu.ie3.datamodel.exceptions; + +public class NotImplementedException extends UnsupportedOperationException { + public NotImplementedException(String msg) { + super(msg); + } +} diff --git a/src/main/java/edu/ie3/datamodel/io/factory/timeseries/IconTimeBasedWeatherValueFactory.java b/src/main/java/edu/ie3/datamodel/io/factory/timeseries/IconTimeBasedWeatherValueFactory.java index 6b3fd419e..1181963be 100644 --- a/src/main/java/edu/ie3/datamodel/io/factory/timeseries/IconTimeBasedWeatherValueFactory.java +++ b/src/main/java/edu/ie3/datamodel/io/factory/timeseries/IconTimeBasedWeatherValueFactory.java @@ -24,7 +24,7 @@ /** * Factory implementation of {@link TimeBasedWeatherValueFactory}, that is able to handle field to - * value mapping in the column scheme, ie3 uses to store it's data from German Federal + * value mapping in the column scheme, ie3 uses to store its data from German Federal * Weather Service's ICON-EU model */ public class IconTimeBasedWeatherValueFactory extends TimeBasedWeatherValueFactory { diff --git a/src/main/java/edu/ie3/datamodel/io/processor/input/InputEntityProcessor.java b/src/main/java/edu/ie3/datamodel/io/processor/input/InputEntityProcessor.java index 398f404aa..971a81d22 100644 --- a/src/main/java/edu/ie3/datamodel/io/processor/input/InputEntityProcessor.java +++ b/src/main/java/edu/ie3/datamodel/io/processor/input/InputEntityProcessor.java @@ -23,7 +23,7 @@ import java.util.List; /** - * Processes all {@link InputEntity}s and it's child classes + * Processes all {@link InputEntity}s and its child classes * * @version 0.1 * @since 23.03.20 diff --git a/src/main/java/edu/ie3/datamodel/io/sink/InfluxDbSink.java b/src/main/java/edu/ie3/datamodel/io/sink/InfluxDbSink.java index 7c2f7b9f8..157ec6013 100644 --- a/src/main/java/edu/ie3/datamodel/io/sink/InfluxDbSink.java +++ b/src/main/java/edu/ie3/datamodel/io/sink/InfluxDbSink.java @@ -155,7 +155,7 @@ private , V extends Value> Set transformToPo String valueClassName = timeSeries.getEntries().iterator().next().getValue().getClass().getSimpleName(); log.warn( - "I could not get a measurement name for TimeSeries value class {}. I am using it's value's simple name instead.", + "I could not get a measurement name for TimeSeries value class {}. I am using its value's simple name instead.", valueClassName); return transformToPoints(timeSeries, valueClassName); } diff --git a/src/main/java/edu/ie3/datamodel/models/StandardUnits.java b/src/main/java/edu/ie3/datamodel/models/StandardUnits.java index e8c8d96f7..35f98dcfe 100644 --- a/src/main/java/edu/ie3/datamodel/models/StandardUnits.java +++ b/src/main/java/edu/ie3/datamodel/models/StandardUnits.java @@ -78,8 +78,8 @@ public class StandardUnits { /** Voltage angle variation per tap (for transformers) in ° (arc degree) */ public static final Unit DPHI_TAP = DEGREE_GEOM; /** - * Gradient, with which a system participant can change it's set point (with regard to rated - * active power = rated apparent power * rated power factor) in %/h + * Gradient, with which a system participant can change its set point (with regard to rated active + * power = rated apparent power * rated power factor) in %/h */ public static final Unit ACTIVE_POWER_GRADIENT = PERCENT_PER_HOUR; /** Efficiency of a process in % */ diff --git a/src/main/java/edu/ie3/datamodel/models/input/AssetTypeInput.java b/src/main/java/edu/ie3/datamodel/models/input/AssetTypeInput.java index 907280676..6e3a558e4 100644 --- a/src/main/java/edu/ie3/datamodel/models/input/AssetTypeInput.java +++ b/src/main/java/edu/ie3/datamodel/models/input/AssetTypeInput.java @@ -43,4 +43,35 @@ public int hashCode() { public String toString() { return "AssetTypeInput{" + "uuid=" + getUuid() + ", id=" + id + "}"; } + + /** + * Abstract class for all builder that build child entities of abstract class {@link + * AssetTypeInput} + */ + public abstract static class AssetTypeInputCopyBuilder< + B extends AssetTypeInput.AssetTypeInputCopyBuilder> + extends UniqueEntityCopyBuilder { + + private String id; + + protected AssetTypeInputCopyBuilder(AssetTypeInput entity) { + super(entity); + this.id = entity.getId(); + } + + public B id(String id) { + this.id = id; + return thisInstance(); + } + + protected String getId() { + return id; + } + + @Override + public abstract AssetTypeInput build(); + + @Override + protected abstract B thisInstance(); + } } diff --git a/src/main/java/edu/ie3/datamodel/models/input/connector/Transformer3WInput.java b/src/main/java/edu/ie3/datamodel/models/input/connector/Transformer3WInput.java index f5b68d97e..6b2b01efa 100644 --- a/src/main/java/edu/ie3/datamodel/models/input/connector/Transformer3WInput.java +++ b/src/main/java/edu/ie3/datamodel/models/input/connector/Transformer3WInput.java @@ -79,7 +79,7 @@ public Transformer3WInput( * transformer (here: that not holds node A in its grid). * *

Then, the internal node becomes a virtual representation of a slack node for the grid and - * allows for power flow calculations based on it's 'close-to-T-equivalent' representation + * allows for power flow calculations based on its 'close-to-T-equivalent' representation * * @param uuid of the input entity * @param id of the asset diff --git a/src/main/java/edu/ie3/datamodel/models/input/container/ThermalGrid.java b/src/main/java/edu/ie3/datamodel/models/input/container/ThermalGrid.java index 3b6d277cc..b3616bc70 100644 --- a/src/main/java/edu/ie3/datamodel/models/input/container/ThermalGrid.java +++ b/src/main/java/edu/ie3/datamodel/models/input/container/ThermalGrid.java @@ -10,6 +10,7 @@ import edu.ie3.datamodel.models.input.thermal.ThermalInput; import edu.ie3.datamodel.models.input.thermal.ThermalStorageInput; import java.util.*; +import java.util.stream.Collectors; /** * Container object to denote a fully connected thermal "grid". As there are currently no branch @@ -108,6 +109,18 @@ public ThermalGridCopyBuilder storages(Set storages) { return this; } + public ThermalGridCopyBuilder scale(Double factor) { + houses( + houses.stream() + .map(house -> house.copy().scale(factor).build()) + .collect(Collectors.toSet())); + storages( + storages.stream() + .map(storage -> storage.copy().scale(factor).build()) + .collect(Collectors.toSet())); + return this; + } + @Override public ThermalGrid build() { return new ThermalGrid(bus, houses, storages); diff --git a/src/main/java/edu/ie3/datamodel/models/input/system/BmInput.java b/src/main/java/edu/ie3/datamodel/models/input/system/BmInput.java index 5ebb38e9d..9ddb9533d 100644 --- a/src/main/java/edu/ie3/datamodel/models/input/system/BmInput.java +++ b/src/main/java/edu/ie3/datamodel/models/input/system/BmInput.java @@ -205,6 +205,12 @@ public BmInputCopyBuilder feedInTariff(ComparableQuantity feedInTar return this; } + @Override + public BmInputCopyBuilder scale(Double factor) { + this.type = this.type.copy().scale(factor).build(); + return this; + } + @Override public BmInput build() { return new BmInput( diff --git a/src/main/java/edu/ie3/datamodel/models/input/system/ChpInput.java b/src/main/java/edu/ie3/datamodel/models/input/system/ChpInput.java index 1478c949b..f68d842a1 100644 --- a/src/main/java/edu/ie3/datamodel/models/input/system/ChpInput.java +++ b/src/main/java/edu/ie3/datamodel/models/input/system/ChpInput.java @@ -222,6 +222,12 @@ public ChpInputCopyBuilder marketReaction(boolean marketReaction) { return this; } + @Override + public ChpInputCopyBuilder scale(Double factor) { + this.type = this.type.copy().scale(factor).build(); + return this; + } + @Override protected ChpInputCopyBuilder thisInstance() { return this; diff --git a/src/main/java/edu/ie3/datamodel/models/input/system/EvInput.java b/src/main/java/edu/ie3/datamodel/models/input/system/EvInput.java index b4796b844..0ddb4b21c 100644 --- a/src/main/java/edu/ie3/datamodel/models/input/system/EvInput.java +++ b/src/main/java/edu/ie3/datamodel/models/input/system/EvInput.java @@ -127,6 +127,17 @@ private EvInputCopyBuilder(EvInput entity) { this.type = entity.getType(); } + public EvInputCopyBuilder type(EvTypeInput type) { + this.type = type; + return this; + } + + @Override + public EvInputCopyBuilder scale(Double factor) { + type(type.copy().scale(factor).build()); + return this; + } + @Override public EvInput build() { return new EvInput( @@ -140,11 +151,6 @@ public EvInput build() { type); } - public EvInputCopyBuilder type(EvTypeInput type) { - this.type = type; - return this; - } - @Override protected EvInputCopyBuilder thisInstance() { return this; diff --git a/src/main/java/edu/ie3/datamodel/models/input/system/EvcsInput.java b/src/main/java/edu/ie3/datamodel/models/input/system/EvcsInput.java index 8513edd5c..6bc40adfb 100644 --- a/src/main/java/edu/ie3/datamodel/models/input/system/EvcsInput.java +++ b/src/main/java/edu/ie3/datamodel/models/input/system/EvcsInput.java @@ -283,6 +283,12 @@ public EvcsInputCopyBuilder v2gSupport(boolean v2gSupport) { return this; } + @Override + public EvcsInputCopyBuilder scale(Double factor) { + type(type.copy().scale(factor).build()); + return this; + } + @Override public EvcsInput build() { return new EvcsInput( diff --git a/src/main/java/edu/ie3/datamodel/models/input/system/FixedFeedInInput.java b/src/main/java/edu/ie3/datamodel/models/input/system/FixedFeedInInput.java index b765ca695..d0580202f 100644 --- a/src/main/java/edu/ie3/datamodel/models/input/system/FixedFeedInInput.java +++ b/src/main/java/edu/ie3/datamodel/models/input/system/FixedFeedInInput.java @@ -144,6 +144,22 @@ private FixedFeedInInputCopyBuilder(FixedFeedInInput entity) { this.cosPhiRated = entity.getCosPhiRated(); } + public FixedFeedInInputCopyBuilder sRated(ComparableQuantity sRated) { + this.sRated = sRated; + return this; + } + + public FixedFeedInInputCopyBuilder cosPhiRated(double cosPhiRated) { + this.cosPhiRated = cosPhiRated; + return this; + } + + @Override + public FixedFeedInInputCopyBuilder scale(Double factor) { + sRated(sRated.multiply(factor)); + return this; + } + @Override public FixedFeedInInput build() { return new FixedFeedInInput( @@ -158,16 +174,6 @@ public FixedFeedInInput build() { cosPhiRated); } - public FixedFeedInInputCopyBuilder sRated(ComparableQuantity sRated) { - this.sRated = sRated; - return this; - } - - public FixedFeedInInputCopyBuilder cosPhiRated(double cosPhiRated) { - this.cosPhiRated = cosPhiRated; - return this; - } - @Override protected FixedFeedInInputCopyBuilder thisInstance() { return this; diff --git a/src/main/java/edu/ie3/datamodel/models/input/system/HpInput.java b/src/main/java/edu/ie3/datamodel/models/input/system/HpInput.java index 89771ae58..bd1aff3e2 100644 --- a/src/main/java/edu/ie3/datamodel/models/input/system/HpInput.java +++ b/src/main/java/edu/ie3/datamodel/models/input/system/HpInput.java @@ -146,6 +146,22 @@ private HpInputCopyBuilder(HpInput entity) { this.thermalBus = entity.getThermalBus(); } + public HpInputCopyBuilder type(HpTypeInput type) { + this.type = type; + return this; + } + + public HpInputCopyBuilder thermalBus(ThermalBusInput thermalBus) { + this.thermalBus = thermalBus; + return this; + } + + @Override + public HpInputCopyBuilder scale(Double factor) { + type(type.copy().scale(factor).build()); + return this; + } + @Override public HpInput build() { return new HpInput( @@ -160,16 +176,6 @@ public HpInput build() { type); } - public HpInputCopyBuilder type(HpTypeInput type) { - this.type = type; - return this; - } - - public HpInputCopyBuilder thermalBus(ThermalBusInput thermalBus) { - this.thermalBus = thermalBus; - return this; - } - @Override protected HpInputCopyBuilder thisInstance() { return this; diff --git a/src/main/java/edu/ie3/datamodel/models/input/system/LoadInput.java b/src/main/java/edu/ie3/datamodel/models/input/system/LoadInput.java index 196952d65..924af0c89 100644 --- a/src/main/java/edu/ie3/datamodel/models/input/system/LoadInput.java +++ b/src/main/java/edu/ie3/datamodel/models/input/system/LoadInput.java @@ -317,6 +317,13 @@ public LoadInputCopyBuilder cosPhiRated(double cosPhiRated) { return this; } + @Override + public LoadInputCopyBuilder scale(Double factor) { + eConsAnnual(eConsAnnual.multiply(factor)); + sRated(sRated.multiply(factor)); + return this; + } + @Override public LoadInput build() { return new LoadInput( diff --git a/src/main/java/edu/ie3/datamodel/models/input/system/PvInput.java b/src/main/java/edu/ie3/datamodel/models/input/system/PvInput.java index 2117ef313..47812390f 100644 --- a/src/main/java/edu/ie3/datamodel/models/input/system/PvInput.java +++ b/src/main/java/edu/ie3/datamodel/models/input/system/PvInput.java @@ -321,6 +321,12 @@ public PvInputCopyBuilder cosPhiRated(double cosPhiRated) { return this; } + @Override + public PvInputCopyBuilder scale(Double factor) { + this.sRated = this.sRated.multiply(factor); + return this; + } + @Override public PvInput build() { return new PvInput( diff --git a/src/main/java/edu/ie3/datamodel/models/input/system/StorageInput.java b/src/main/java/edu/ie3/datamodel/models/input/system/StorageInput.java index ed37c1448..ec4cc3ddc 100644 --- a/src/main/java/edu/ie3/datamodel/models/input/system/StorageInput.java +++ b/src/main/java/edu/ie3/datamodel/models/input/system/StorageInput.java @@ -127,6 +127,17 @@ private StorageInputCopyBuilder(StorageInput entity) { this.type = entity.getType(); } + public StorageInputCopyBuilder type(StorageTypeInput type) { + this.type = type; + return this; + } + + @Override + public StorageInputCopyBuilder scale(Double factor) { + type(type.copy().scale(factor).build()); + return this; + } + @Override public StorageInput build() { return new StorageInput( @@ -140,11 +151,6 @@ public StorageInput build() { type); } - public StorageInputCopyBuilder type(StorageTypeInput type) { - this.type = type; - return this; - } - @Override protected StorageInputCopyBuilder thisInstance() { return this; diff --git a/src/main/java/edu/ie3/datamodel/models/input/system/SystemParticipantInput.java b/src/main/java/edu/ie3/datamodel/models/input/system/SystemParticipantInput.java index eea7df273..223dffe44 100644 --- a/src/main/java/edu/ie3/datamodel/models/input/system/SystemParticipantInput.java +++ b/src/main/java/edu/ie3/datamodel/models/input/system/SystemParticipantInput.java @@ -181,6 +181,16 @@ public EmInput getEm() { return em; } + /** + * Scales the input entity in a way that tries to preserve proportions that are related to + * power. This means that capacity, consumption etc. are scaled with the same factor. Related + * properties associated with the input type (if applicable) are scaled as well. + * + * @param factor The factor to scale with + * @return A copy builder with scaled relevant properties + */ + public abstract B scale(Double factor); + @Override public abstract SystemParticipantInput build(); diff --git a/src/main/java/edu/ie3/datamodel/models/input/system/WecInput.java b/src/main/java/edu/ie3/datamodel/models/input/system/WecInput.java index 05d170e59..949708f66 100644 --- a/src/main/java/edu/ie3/datamodel/models/input/system/WecInput.java +++ b/src/main/java/edu/ie3/datamodel/models/input/system/WecInput.java @@ -145,6 +145,12 @@ private WecInputCopyBuilder(WecInput entity) { this.marketReaction = entity.isMarketReaction(); } + @Override + public WecInputCopyBuilder scale(Double factor) { + type(type.copy().scale(factor).build()); + return this; + } + @Override public WecInput build() { return new WecInput( diff --git a/src/main/java/edu/ie3/datamodel/models/input/system/type/BmTypeInput.java b/src/main/java/edu/ie3/datamodel/models/input/system/type/BmTypeInput.java index ad150174a..b3cd3c7ce 100644 --- a/src/main/java/edu/ie3/datamodel/models/input/system/type/BmTypeInput.java +++ b/src/main/java/edu/ie3/datamodel/models/input/system/type/BmTypeInput.java @@ -55,6 +55,11 @@ public ComparableQuantity getEtaConv() { return etaConv; } + @Override + public BmTypeInputCopyBuilder copy() { + return new BmTypeInputCopyBuilder(this); + } + @Override public boolean equals(Object o) { if (this == o) return true; @@ -89,4 +94,65 @@ public String toString() { + etaConv + '}'; } + + /** + * A builder pattern based approach to create copies of {@link BmTypeInput} entities with altered + * field values. For detailed field descriptions refer to java docs of {@link BmTypeInput} + */ + public static class BmTypeInputCopyBuilder + extends SystemParticipantTypeInputCopyBuilder { + + private ComparableQuantity activePowerGradient; + private ComparableQuantity etaConv; + + private BmTypeInputCopyBuilder(BmTypeInput entity) { + super(entity); + this.activePowerGradient = entity.getActivePowerGradient(); + this.etaConv = entity.getEtaConv(); + } + + public BmTypeInputCopyBuilder setActivePowerGradient( + ComparableQuantity activePowerGradient) { + this.activePowerGradient = activePowerGradient; + return this; + } + + public BmTypeInputCopyBuilder setEtaConv(ComparableQuantity etaConv) { + this.etaConv = etaConv; + return this; + } + + public ComparableQuantity getActivePowerGradient() { + return activePowerGradient; + } + + public ComparableQuantity getEtaConv() { + return etaConv; + } + + @Override + public BmTypeInputCopyBuilder scale(Double factor) { + setCapex(getCapex().multiply(factor)); + setsRated(getsRated().multiply(factor)); + return this; + } + + @Override + public BmTypeInput build() { + return new BmTypeInput( + getUuid(), + getId(), + getCapex(), + getOpex(), + activePowerGradient, + getsRated(), + getCosPhiRated(), + etaConv); + } + + @Override + protected BmTypeInputCopyBuilder thisInstance() { + return this; + } + } } diff --git a/src/main/java/edu/ie3/datamodel/models/input/system/type/ChpTypeInput.java b/src/main/java/edu/ie3/datamodel/models/input/system/type/ChpTypeInput.java index d4d1f6abe..498d577c0 100644 --- a/src/main/java/edu/ie3/datamodel/models/input/system/type/ChpTypeInput.java +++ b/src/main/java/edu/ie3/datamodel/models/input/system/type/ChpTypeInput.java @@ -71,6 +71,11 @@ public ComparableQuantity getpOwn() { return pOwn; } + @Override + public ChpTypeInputCopyBuilder copy() { + return new ChpTypeInputCopyBuilder(this); + } + @Override public boolean equals(Object o) { if (this == o) return true; @@ -112,4 +117,90 @@ public String toString() { + pOwn + '}'; } + + /** + * A builder pattern based approach to create copies of {@link ChpTypeInput} entities with altered + * field values. For detailed field descriptions refer to java docs of {@link ChpTypeInput} + */ + public static class ChpTypeInputCopyBuilder + extends SystemParticipantTypeInputCopyBuilder { + + private ComparableQuantity etaEl; + private ComparableQuantity etaThermal; + private ComparableQuantity pThermal; + private ComparableQuantity pOwn; + + private ChpTypeInputCopyBuilder(ChpTypeInput entity) { + super(entity); + this.etaEl = entity.getEtaEl(); + this.etaThermal = entity.getEtaThermal(); + this.pThermal = entity.getpThermal(); + this.pOwn = entity.getpOwn(); + } + + public ChpTypeInputCopyBuilder setEtaEl(ComparableQuantity etaEl) { + this.etaEl = etaEl; + return this; + } + + public ChpTypeInputCopyBuilder setEtaThermal(ComparableQuantity etaThermal) { + this.etaThermal = etaThermal; + return this; + } + + public ChpTypeInputCopyBuilder setpThermal(ComparableQuantity pThermal) { + this.pThermal = pThermal; + return this; + } + + public ChpTypeInputCopyBuilder setpOwn(ComparableQuantity pOwn) { + this.pOwn = pOwn; + return this; + } + + public ComparableQuantity getEtaEl() { + return etaEl; + } + + public ComparableQuantity getEtaThermal() { + return etaThermal; + } + + public ComparableQuantity getpThermal() { + return pThermal; + } + + public ComparableQuantity getpOwn() { + return pOwn; + } + + @Override + public ChpTypeInput.ChpTypeInputCopyBuilder scale(Double factor) { + setCapex(getCapex().multiply(factor)); + setsRated(getsRated().multiply(factor)); + setpThermal(getpThermal().multiply(factor)); + setpOwn(getpOwn().multiply(factor)); + return this; + } + + @Override + public ChpTypeInput build() { + return new ChpTypeInput( + getUuid(), + getId(), + getCapex(), + getOpex(), + etaEl, + etaThermal, + getsRated(), + getCosPhiRated(), + pThermal, + pOwn); + } + + @Override + protected ChpTypeInput.ChpTypeInputCopyBuilder thisInstance() { + return this; + } + } } diff --git a/src/main/java/edu/ie3/datamodel/models/input/system/type/EvTypeInput.java b/src/main/java/edu/ie3/datamodel/models/input/system/type/EvTypeInput.java index 465a1ae90..0402b026d 100644 --- a/src/main/java/edu/ie3/datamodel/models/input/system/type/EvTypeInput.java +++ b/src/main/java/edu/ie3/datamodel/models/input/system/type/EvTypeInput.java @@ -54,6 +54,11 @@ public ComparableQuantity geteCons() { return eCons; } + @Override + public EvTypeInputCopyBuilder copy() { + return new EvTypeInputCopyBuilder(this); + } + @Override public boolean equals(Object o) { if (this == o) return true; @@ -88,4 +93,66 @@ public String toString() { + eCons + '}'; } + + /** + * A builder pattern based approach to create copies of {@link EvTypeInput} entities with altered + * field values. For detailed field descriptions refer to java docs of {@link EvTypeInput} + */ + public static class EvTypeInputCopyBuilder + extends SystemParticipantTypeInputCopyBuilder { + + private ComparableQuantity eStorage; + private ComparableQuantity eCons; + + private EvTypeInputCopyBuilder(EvTypeInput entity) { + super(entity); + this.eStorage = entity.geteStorage(); + this.eCons = entity.geteCons(); + } + + public EvTypeInputCopyBuilder seteStorage(ComparableQuantity eStorage) { + this.eStorage = eStorage; + return this; + } + + public EvTypeInputCopyBuilder seteCons(ComparableQuantity eCons) { + this.eCons = eCons; + return this; + } + + public ComparableQuantity geteStorage() { + return eStorage; + } + + public ComparableQuantity geteCons() { + return eCons; + } + + @Override + public EvTypeInput.EvTypeInputCopyBuilder scale(Double factor) { + setCapex(getCapex().multiply(factor)); + setsRated(getsRated().multiply(factor)); + seteStorage(geteStorage().multiply(factor)); + seteCons(geteCons().multiply(factor)); + return this; + } + + @Override + public EvTypeInput build() { + return new EvTypeInput( + getUuid(), + getId(), + getCapex(), + getOpex(), + eStorage, + eCons, + getsRated(), + getCosPhiRated()); + } + + @Override + protected EvTypeInput.EvTypeInputCopyBuilder thisInstance() { + return this; + } + } } diff --git a/src/main/java/edu/ie3/datamodel/models/input/system/type/HpTypeInput.java b/src/main/java/edu/ie3/datamodel/models/input/system/type/HpTypeInput.java index fb2532413..4b5edeeb5 100644 --- a/src/main/java/edu/ie3/datamodel/models/input/system/type/HpTypeInput.java +++ b/src/main/java/edu/ie3/datamodel/models/input/system/type/HpTypeInput.java @@ -44,6 +44,11 @@ public ComparableQuantity getpThermal() { return pThermal; } + @Override + public HpTypeInputCopyBuilder copy() { + return new HpTypeInputCopyBuilder(this); + } + @Override public boolean equals(Object o) { if (this == o) return true; @@ -76,4 +81,47 @@ public String toString() { + pThermal + '}'; } + + /** + * A builder pattern based approach to create copies of {@link HpTypeInput} entities with altered + * field values. For detailed field descriptions refer to java docs of {@link HpTypeInput} + */ + public static class HpTypeInputCopyBuilder + extends SystemParticipantTypeInputCopyBuilder { + + private ComparableQuantity pThermal; + + private HpTypeInputCopyBuilder(HpTypeInput entity) { + super(entity); + this.pThermal = entity.getpThermal(); + } + + public HpTypeInputCopyBuilder setpThermal(ComparableQuantity pThermal) { + this.pThermal = pThermal; + return this; + } + + public ComparableQuantity getpThermal() { + return pThermal; + } + + @Override + public HpTypeInput.HpTypeInputCopyBuilder scale(Double factor) { + setCapex(getCapex().multiply(factor)); + setsRated(getsRated().multiply(factor)); + setpThermal(getpThermal().multiply(factor)); + return this; + } + + @Override + public HpTypeInput build() { + return new HpTypeInput( + getUuid(), getId(), getCapex(), getOpex(), getsRated(), getCosPhiRated(), pThermal); + } + + @Override + protected HpTypeInput.HpTypeInputCopyBuilder thisInstance() { + return this; + } + } } diff --git a/src/main/java/edu/ie3/datamodel/models/input/system/type/StorageTypeInput.java b/src/main/java/edu/ie3/datamodel/models/input/system/type/StorageTypeInput.java index 4358631b9..29892b868 100644 --- a/src/main/java/edu/ie3/datamodel/models/input/system/type/StorageTypeInput.java +++ b/src/main/java/edu/ie3/datamodel/models/input/system/type/StorageTypeInput.java @@ -101,6 +101,11 @@ public ComparableQuantity getActivePowerGradient() { return activePowerGradient; } + @Override + public StorageTypeInputCopyBuilder copy() { + return new StorageTypeInputCopyBuilder(this); + } + @Override public boolean equals(Object o) { if (this == o) return true; @@ -152,4 +157,128 @@ public String toString() { + lifeCycle + '}'; } + + /** + * A builder pattern based approach to create copies of {@link StorageTypeInput} entities with + * altered field values. For detailed field descriptions refer to java docs of {@link + * StorageTypeInput} + */ + public static class StorageTypeInputCopyBuilder + extends SystemParticipantTypeInputCopyBuilder { + + private ComparableQuantity eStorage; + private ComparableQuantity pMax; + private ComparableQuantity activePowerGradient; + private ComparableQuantity eta; + private ComparableQuantity dod; + private ComparableQuantity