Skip to content

Commit

Permalink
add @NotNull annotation
Browse files Browse the repository at this point in the history
  • Loading branch information
thangqp committed Sep 12, 2024
1 parent 328a825 commit cb66651
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 <Seddik.yengui at rte-france.com>
Expand All @@ -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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import com.powsybl.iidm.network.Generator;
import com.powsybl.iidm.network.extensions.*;
import jakarta.validation.constraints.NotNull;

/**
* @author Seddik Yengui <Seddik.yengui at rte-france.com>
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import com.powsybl.iidm.network.Load;
import com.powsybl.iidm.network.LoadType;
import jakarta.validation.constraints.NotNull;

/**
* @author Seddik Yengui <Seddik.yengui at rte-france.com>
Expand All @@ -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));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand All @@ -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()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 <Seddik.yengui at rte-france.com>
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 <Seddik.yengui at rte-france.com>
Expand All @@ -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<VoltageLevel> identifiableShortCircuit = voltageLevel.getExtension(IdentifiableShortCircuit.class);
VoltageLevelField field = VoltageLevelField.valueOf(voltageLevelField);
switch (field) {
Expand Down

0 comments on commit cb66651

Please sign in to comment.