diff --git a/src/main/java/org/gridsuite/modification/server/dto/byfilter/equipmentfield/BatteryField.java b/src/main/java/org/gridsuite/modification/server/dto/byfilter/equipmentfield/BatteryField.java index fc4302327..5de8a455a 100644 --- a/src/main/java/org/gridsuite/modification/server/dto/byfilter/equipmentfield/BatteryField.java +++ b/src/main/java/org/gridsuite/modification/server/dto/byfilter/equipmentfield/BatteryField.java @@ -10,6 +10,7 @@ import com.powsybl.iidm.network.Battery; import com.powsybl.iidm.network.extensions.ActivePowerControl; import com.powsybl.iidm.network.extensions.ActivePowerControlAdder; +import jakarta.validation.constraints.NotNull; /** * @author Seddik Yengui @@ -34,7 +35,7 @@ public static String getReferenceValue(Battery battery, String batteryField) { }; } - public static void setNewValue(Battery battery, String batteryField, String newValue) { + public static void setNewValue(Battery battery, String batteryField, @NotNull String newValue) { BatteryField field = BatteryField.valueOf(batteryField); switch (field) { case MINIMUM_ACTIVE_POWER -> battery.setMinP(Double.parseDouble(newValue)); diff --git a/src/main/java/org/gridsuite/modification/server/dto/byfilter/equipmentfield/GeneratorField.java b/src/main/java/org/gridsuite/modification/server/dto/byfilter/equipmentfield/GeneratorField.java index 2cd1d37fb..606a7f145 100644 --- a/src/main/java/org/gridsuite/modification/server/dto/byfilter/equipmentfield/GeneratorField.java +++ b/src/main/java/org/gridsuite/modification/server/dto/byfilter/equipmentfield/GeneratorField.java @@ -9,6 +9,7 @@ import com.powsybl.iidm.network.Generator; import com.powsybl.iidm.network.extensions.*; +import jakarta.validation.constraints.NotNull; /** * @author Seddik Yengui @@ -55,7 +56,7 @@ public static String getReferenceValue(Generator generator, String generatorFiel }; } - public static void setNewValue(Generator generator, String generatorField, String newValue) { + public static void setNewValue(Generator generator, String generatorField, @NotNull String newValue) { GeneratorStartup generatorStartup = generator.getExtension(GeneratorStartup.class); GeneratorShortCircuit generatorShortCircuit = generator.getExtension(GeneratorShortCircuit.class); GeneratorField field = GeneratorField.valueOf(generatorField); diff --git a/src/main/java/org/gridsuite/modification/server/dto/byfilter/equipmentfield/LoadField.java b/src/main/java/org/gridsuite/modification/server/dto/byfilter/equipmentfield/LoadField.java index 4582df7d1..5660ce009 100644 --- a/src/main/java/org/gridsuite/modification/server/dto/byfilter/equipmentfield/LoadField.java +++ b/src/main/java/org/gridsuite/modification/server/dto/byfilter/equipmentfield/LoadField.java @@ -9,6 +9,7 @@ import com.powsybl.iidm.network.Load; import com.powsybl.iidm.network.LoadType; +import jakarta.validation.constraints.NotNull; /** * @author Seddik Yengui @@ -27,10 +28,10 @@ public static String getReferenceValue(Load load, String loadField) { }; } - public static void setNewValue(Load load, String loadField, String newValue) { + public static void setNewValue(Load load, String loadField, @NotNull String newValue) { LoadField field = LoadField.valueOf(loadField); switch (field) { - case LOAD_TYPE -> load.setLoadType(newValue != null ? LoadType.valueOf(newValue) : null); + case LOAD_TYPE -> load.setLoadType(LoadType.valueOf(newValue)); case ACTIVE_POWER -> load.setP0(Double.parseDouble(newValue)); case REACTIVE_POWER -> load.setQ0(Double.parseDouble(newValue)); } diff --git a/src/main/java/org/gridsuite/modification/server/dto/byfilter/equipmentfield/ShuntCompensatorField.java b/src/main/java/org/gridsuite/modification/server/dto/byfilter/equipmentfield/ShuntCompensatorField.java index 82ecc1a94..cb7894461 100644 --- a/src/main/java/org/gridsuite/modification/server/dto/byfilter/equipmentfield/ShuntCompensatorField.java +++ b/src/main/java/org/gridsuite/modification/server/dto/byfilter/equipmentfield/ShuntCompensatorField.java @@ -11,6 +11,7 @@ import com.powsybl.iidm.network.ShuntCompensatorLinearModel; import com.powsybl.iidm.network.ShuntCompensatorModelType; import com.powsybl.iidm.network.VoltageLevel; +import jakarta.validation.constraints.NotNull; import org.gridsuite.modification.server.NetworkModificationException; /** @@ -33,7 +34,7 @@ public static String getReferenceValue(ShuntCompensator shuntCompensator, String }; } - public static void setNewValue(ShuntCompensator shuntCompensator, String shuntCompensatorField, String newValue) { + public static void setNewValue(ShuntCompensator shuntCompensator, String shuntCompensatorField, @NotNull String newValue) { if (shuntCompensator.getModelType() != ShuntCompensatorModelType.LINEAR) { throw new NetworkModificationException(NetworkModificationException.Type.BY_FORMULA_MODIFICATION_ERROR, String.format("Shunt compensator with %s model is not supported", shuntCompensator.getModelType())); diff --git a/src/main/java/org/gridsuite/modification/server/dto/byfilter/equipmentfield/TwoWindingsTransformerField.java b/src/main/java/org/gridsuite/modification/server/dto/byfilter/equipmentfield/TwoWindingsTransformerField.java index b60bfa937..5d3af2fbe 100644 --- a/src/main/java/org/gridsuite/modification/server/dto/byfilter/equipmentfield/TwoWindingsTransformerField.java +++ b/src/main/java/org/gridsuite/modification/server/dto/byfilter/equipmentfield/TwoWindingsTransformerField.java @@ -10,6 +10,7 @@ import com.powsybl.iidm.network.PhaseTapChanger; import com.powsybl.iidm.network.RatioTapChanger; import com.powsybl.iidm.network.TwoWindingsTransformer; +import jakarta.validation.constraints.NotNull; /** * @author Seddik Yengui @@ -54,7 +55,7 @@ public static String getReferenceValue(TwoWindingsTransformer transformer, Strin }; } - public static void setNewValue(TwoWindingsTransformer transformer, String twoWindingsTransformerField, String newValue) { + public static void setNewValue(TwoWindingsTransformer transformer, String twoWindingsTransformerField, @NotNull String newValue) { TwoWindingsTransformerField field = TwoWindingsTransformerField.valueOf(twoWindingsTransformerField); final PhaseTapChanger phaseTapChanger = transformer.getPhaseTapChanger(); final RatioTapChanger ratioTapChanger = transformer.getRatioTapChanger(); diff --git a/src/main/java/org/gridsuite/modification/server/dto/byfilter/equipmentfield/VoltageLevelField.java b/src/main/java/org/gridsuite/modification/server/dto/byfilter/equipmentfield/VoltageLevelField.java index 2303457c2..bbede673a 100644 --- a/src/main/java/org/gridsuite/modification/server/dto/byfilter/equipmentfield/VoltageLevelField.java +++ b/src/main/java/org/gridsuite/modification/server/dto/byfilter/equipmentfield/VoltageLevelField.java @@ -10,6 +10,7 @@ import com.powsybl.iidm.network.VoltageLevel; import com.powsybl.iidm.network.extensions.IdentifiableShortCircuit; import com.powsybl.iidm.network.extensions.IdentifiableShortCircuitAdder; +import jakarta.validation.constraints.NotNull; /** * @author Seddik Yengui @@ -33,7 +34,7 @@ public static String getReferenceValue(VoltageLevel voltageLevel, String voltage }; } - public static void setNewValue(VoltageLevel voltageLevel, String voltageLevelField, String newValue) { + public static void setNewValue(VoltageLevel voltageLevel, String voltageLevelField, @NotNull String newValue) { IdentifiableShortCircuit identifiableShortCircuit = voltageLevel.getExtension(IdentifiableShortCircuit.class); VoltageLevelField field = VoltageLevelField.valueOf(voltageLevelField); switch (field) {