Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add add method to the adders API #2502

Merged
merged 9 commits into from
Mar 14, 2023
Merged
Show file tree
Hide file tree
Changes from 3 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
Original file line number Diff line number Diff line change
Expand Up @@ -516,23 +516,23 @@ static class TerminalData {

// Connections

public void connect(InjectionAdder<?> adder) {
public void connect(InjectionAdder<?, ?> adder) {
if (context.nodeBreaker()) {
adder.setNode(iidmNode());
} else {
adder.setBus(terminalConnected() ? busId() : null).setConnectableBus(busId());
}
}

public void connect(InjectionAdder<?> adder, int terminal) {
public void connect(InjectionAdder<?, ?> adder, int terminal) {
if (context.nodeBreaker()) {
adder.setNode(iidmNode(terminal));
} else {
adder.setBus(terminalConnected(terminal) ? busId(terminal) : null).setConnectableBus(busId(terminal));
}
}

public void connect(BranchAdder<?> adder) {
public void connect(BranchAdder<?, ?> adder) {
if (context.nodeBreaker()) {
adder
.setVoltageLevel1(iidmVoltageLevelId(1))
Expand All @@ -552,13 +552,13 @@ public void connect(BranchAdder<?> adder) {
}
}

public void connect(BranchAdder<?> adder,
public void connect(BranchAdder<?, ?> adder,
String iidmVoltageLevelId1, String busId1, boolean t1Connected, int node1,
String iidmVoltageLevelId2, String busId2, boolean t2Connected, int node2) {
connect(context, adder, iidmVoltageLevelId1, busId1, t1Connected, node1, iidmVoltageLevelId2, busId2, t2Connected, node2);
}

public static void connect(Context context, BranchAdder<?> adder,
public static void connect(Context context, BranchAdder<?, ?> adder,
String iidmVoltageLevelId1, String busId1, boolean t1Connected, int node1,
String iidmVoltageLevelId2, String busId2, boolean t2Connected, int node2) {
if (context.nodeBreaker()) {
Expand All @@ -578,11 +578,11 @@ public static void connect(Context context, BranchAdder<?> adder,
}
}

public void connect(BranchAdder<?> adder, boolean t1Connected, boolean t2Connected) {
public void connect(BranchAdder<?, ?> adder, boolean t1Connected, boolean t2Connected) {
connect(adder, t1Connected, t2Connected, true);
}

public void connect(BranchAdder<?> adder, boolean t1Connected, boolean t2Connected, boolean branchIsClosed) {
public void connect(BranchAdder<?, ?> adder, boolean t1Connected, boolean t2Connected, boolean branchIsClosed) {
if (context.nodeBreaker()) {
adder
.setVoltageLevel1(iidmVoltageLevelId(1))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,19 +55,19 @@ public String iidmName() {

// Identification

public void identify(IdentifiableAdder<?> adder) {
public void identify(IdentifiableAdder<?, ?> adder) {
identify(adder, iidmId(), iidmName());
}

public void identify(IdentifiableAdder<?> adder, String duplicatedTag) {
public void identify(IdentifiableAdder<?, ?> adder, String duplicatedTag) {
identify(adder, iidmId() + duplicatedTag, iidmName() + duplicatedTag);
}

public void identify(IdentifiableAdder<?> adder, String id, String name) {
public void identify(IdentifiableAdder<?, ?> adder, String id, String name) {
identify(context, adder, id, name);
}

public static void identify(Context context, IdentifiableAdder<?> adder, String id, String name) {
public static void identify(Context context, IdentifiableAdder<?, ?> adder, String id, String name) {
adder
.setId(id)
.setName(name)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
* @see Battery
* @see VoltageLevel
*/
public interface BatteryAdder extends InjectionAdder<BatteryAdder> {
public interface BatteryAdder extends InjectionAdder<Battery, BatteryAdder> {

/**
* @deprecated Use {@link #setTargetP(double)} instead.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,23 @@
*
* @author Geoffroy Jamgotchian <geoffroy.jamgotchian at rte-france.com>
*/
public interface BranchAdder<T extends BranchAdder> extends IdentifiableAdder<T> {
public interface BranchAdder<T extends Branch<? super T>, A extends BranchAdder> extends IdentifiableAdder<T, A> {

T setVoltageLevel1(String voltageLevelId1);
A setVoltageLevel1(String voltageLevelId1);

T setNode1(int node1);
A setNode1(int node1);

T setBus1(String bus1);
A setBus1(String bus1);

T setConnectableBus1(String connectableBus1);
A setConnectableBus1(String connectableBus1);

T setVoltageLevel2(String voltageLevelId2);
A setVoltageLevel2(String voltageLevelId2);

T setNode2(int node2);
A setNode2(int node2);

T setBus2(String bus2);
A setBus2(String bus2);

T setConnectableBus2(String connectableBus2);
A setConnectableBus2(String connectableBus2);

T add();
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*
* @author Geoffroy Jamgotchian <geoffroy.jamgotchian at rte-france.com>
*/
public interface BusAdder extends IdentifiableAdder<BusAdder> {
public interface BusAdder extends IdentifiableAdder<Bus, BusAdder> {

Bus add();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*
* @author Geoffroy Jamgotchian <geoffroy.jamgotchian at rte-france.com>
*/
public interface BusbarSectionAdder extends IdentifiableAdder<BusbarSectionAdder> {
public interface BusbarSectionAdder extends IdentifiableAdder<BusbarSection, BusbarSectionAdder> {

BusbarSectionAdder setNode(int node);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
* @see DanglingLine
* @see VoltageLevel
*/
public interface DanglingLineAdder extends InjectionAdder<DanglingLineAdder> {
public interface DanglingLineAdder extends InjectionAdder<DanglingLine, DanglingLineAdder> {

interface GenerationAdder {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
* @see Generator
* @see VoltageLevel
*/
public interface GeneratorAdder extends InjectionAdder<GeneratorAdder> {
public interface GeneratorAdder extends InjectionAdder<Generator, GeneratorAdder> {

GeneratorAdder setEnergySource(EnergySource energySource);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@
*
* @author Mathieu Bague <mathieu.bague at rte-france.com>
*/
public interface HvdcConverterStationAdder<T extends HvdcConverterStationAdder> extends InjectionAdder<T> {
public interface HvdcConverterStationAdder<T extends HvdcConverterStation<T>, A extends HvdcConverterStationAdder> extends InjectionAdder<T, A> {

T setLossFactor(float lossFactor);
A setLossFactor(float lossFactor);

T add();
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* @author Geoffroy Jamgotchian <geoffroy.jamgotchian at rte-france.com>
* @author Mathieu Bague <mathieu.bague at rte-france.com>
*/
public interface HvdcLineAdder extends IdentifiableAdder<HvdcLineAdder> {
public interface HvdcLineAdder extends IdentifiableAdder<HvdcLine, HvdcLineAdder> {

HvdcLineAdder setR(double r);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,17 @@
*
* @author Geoffroy Jamgotchian <geoffroy.jamgotchian at rte-france.com>
*/
public interface IdentifiableAdder<T extends IdentifiableAdder> {
public interface IdentifiableAdder<T extends Identifiable<? super T>, A extends IdentifiableAdder> {

T setId(String id);
A setId(String id);

T setEnsureIdUnicity(boolean ensureIdUnicity);
A setEnsureIdUnicity(boolean ensureIdUnicity);

T setName(String name);
A setName(String name);

default T setFictitious(boolean fictitious) {
default A setFictitious(boolean fictitious) {
throw new UnsupportedOperationException();
}

T add();
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@
*
* @author Geoffroy Jamgotchian <geoffroy.jamgotchian at rte-france.com>
*/
public interface InjectionAdder<T extends InjectionAdder> extends IdentifiableAdder<T> {
public interface InjectionAdder<T extends Injection<? super T>, A extends InjectionAdder> extends IdentifiableAdder<T, A> {

T setNode(int node);
A setNode(int node);

T setBus(String bus);
A setBus(String bus);

T setConnectableBus(String connectableBus);
A setConnectableBus(String connectableBus);

T add();
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* @author Geoffroy Jamgotchian <geoffroy.jamgotchian at rte-france.com>
* @author Mathieu Bague <mathieu.bague at rte-france.com>
*/
public interface LccConverterStationAdder extends HvdcConverterStationAdder<LccConverterStationAdder> {
public interface LccConverterStationAdder extends HvdcConverterStationAdder<LccConverterStation, LccConverterStationAdder> {

LccConverterStationAdder setPowerFactor(float powerFactor);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* @see Line
* @see Network
*/
public interface LineAdder extends BranchAdder<LineAdder> {
public interface LineAdder extends BranchAdder<Line, LineAdder> {

LineAdder setR(double r);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
* @see Load
* @see VoltageLevel
*/
public interface LoadAdder extends InjectionAdder<LoadAdder> {
public interface LoadAdder extends InjectionAdder<Load, LoadAdder> {

LoadAdder setLoadType(LoadType loadType);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
* @see ShuntCompensator
* @see VoltageLevel
*/
public interface ShuntCompensatorAdder extends InjectionAdder<ShuntCompensatorAdder> {
public interface ShuntCompensatorAdder extends InjectionAdder<ShuntCompensator, ShuntCompensatorAdder> {

ShuntCompensatorLinearModelAdder newLinearModel();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
/**
* @author Geoffroy Jamgotchian <geoffroy.jamgotchian at rte-france.com>
*/
public interface StaticVarCompensatorAdder extends InjectionAdder<StaticVarCompensatorAdder> {
public interface StaticVarCompensatorAdder extends InjectionAdder<StaticVarCompensator, StaticVarCompensatorAdder> {

StaticVarCompensatorAdder setBmin(double bMin);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
* @see Substation
* @see Network
*/
public interface SubstationAdder extends IdentifiableAdder<SubstationAdder> {
public interface SubstationAdder extends IdentifiableAdder<Substation, SubstationAdder> {

SubstationAdder setCountry(Country country);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*
* @author Geoffroy Jamgotchian <geoffroy.jamgotchian at rte-france.com>
*/
public interface ThreeWindingsTransformerAdder extends IdentifiableAdder<ThreeWindingsTransformerAdder> {
public interface ThreeWindingsTransformerAdder extends IdentifiableAdder<ThreeWindingsTransformer, ThreeWindingsTransformerAdder> {

public interface LegAdder {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
/**
* @author Geoffroy Jamgotchian <geoffroy.jamgotchian at rte-france.com>
*/
public interface TieLineAdder extends BranchAdder<TieLineAdder> {
public interface TieLineAdder extends BranchAdder<TieLine, TieLineAdder> {

interface HalfLineAdder {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*
* @author Geoffroy Jamgotchian <geoffroy.jamgotchian at rte-france.com>
*/
public interface TwoWindingsTransformerAdder extends BranchAdder<TwoWindingsTransformerAdder> {
public interface TwoWindingsTransformerAdder extends BranchAdder<TwoWindingsTransformer, TwoWindingsTransformerAdder> {

TwoWindingsTransformerAdder setR(double r);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ default NodeBreakerView setFictitiousQ0(int node, double q0) {
return this;
}

interface SwitchAdder extends IdentifiableAdder<SwitchAdder> {
interface SwitchAdder extends IdentifiableAdder<Switch, SwitchAdder> {

SwitchAdder setNode1(int node1);

Expand Down Expand Up @@ -685,7 +685,7 @@ interface TopologyTraverser {
*/
interface BusBreakerView {

interface SwitchAdder extends IdentifiableAdder<SwitchAdder> {
interface SwitchAdder extends IdentifiableAdder<Switch, SwitchAdder> {

SwitchAdder setBus1(String bus1);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*
* @author Geoffroy Jamgotchian <geoffroy.jamgotchian at rte-france.com>
*/
public interface VoltageLevelAdder extends IdentifiableAdder<VoltageLevelAdder> {
public interface VoltageLevelAdder extends IdentifiableAdder<VoltageLevel, VoltageLevelAdder> {

VoltageLevelAdder setNominalV(double nominalV);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* @author Geoffroy Jamgotchian <geoffroy.jamgotchian at rte-france.com>
* @author Mathieu Bague <mathieu.bague at rte-france.com>
*/
public interface VscConverterStationAdder extends HvdcConverterStationAdder<VscConverterStationAdder> {
public interface VscConverterStationAdder extends HvdcConverterStationAdder<VscConverterStation, VscConverterStationAdder> {

VscConverterStationAdder setVoltageRegulatorOn(boolean voltageRegulatorOn);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@
*/
package com.powsybl.iidm.mergingview;

import com.powsybl.iidm.network.HvdcConverterStation;
import com.powsybl.iidm.network.HvdcConverterStationAdder;

/**
* @author Thomas Adam <tadam at silicom.fr>
*/
abstract class AbstractHvdcConverterStationAdderAdapter<I extends HvdcConverterStationAdder<I>> extends AbstractInjectionAdderAdapter<I> implements HvdcConverterStationAdder<I> {
abstract class AbstractHvdcConverterStationAdderAdapter<T extends HvdcConverterStation<T>, I extends HvdcConverterStationAdder<T, I>> extends AbstractInjectionAdderAdapter<T, I> implements HvdcConverterStationAdder<T, I> {

protected AbstractHvdcConverterStationAdderAdapter(I delegate, MergingViewIndex index) {
super(delegate, index);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@
package com.powsybl.iidm.mergingview;

import com.powsybl.commons.PowsyblException;
import com.powsybl.iidm.network.Identifiable;
import com.powsybl.iidm.network.IdentifiableAdder;
import com.powsybl.iidm.network.util.Identifiables;

/**
* @author Thomas Adam <tadam at silicom.fr>
*/
abstract class AbstractIdentifiableAdderAdapter<I extends IdentifiableAdder<I>> extends AbstractAdapter<I> implements IdentifiableAdder<I> {
abstract class AbstractIdentifiableAdderAdapter<T extends Identifiable<? super T>, I extends IdentifiableAdder<T, I>> extends AbstractAdapter<I> implements IdentifiableAdder<T, I> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same question as in BranchAdder

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's again because of TieLine, which makes BranchAdder have the same kind of parameter, and as BranchAdder extends AbstractIdentifiable we need the same here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After the merge I needed the same for AbstractSimpleIdentifiableXml


private String id;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@
*/
package com.powsybl.iidm.mergingview;

import com.powsybl.iidm.network.Injection;
import com.powsybl.iidm.network.InjectionAdder;

/**
* @author Thomas Adam <tadam at silicom.fr>
*/
abstract class AbstractInjectionAdderAdapter<I extends InjectionAdder<I>> extends AbstractIdentifiableAdderAdapter<I> implements InjectionAdder<I> {
abstract class AbstractInjectionAdderAdapter<T extends Injection<T>, I extends InjectionAdder<T, I>> extends AbstractIdentifiableAdderAdapter<T, I> implements InjectionAdder<T, I> {

protected AbstractInjectionAdderAdapter(I delegate, MergingViewIndex index) {
super(delegate, index);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
/**
* @author Thomas Adam <tadam at silicom.fr>
*/
public class BatteryAdderAdapter extends AbstractInjectionAdderAdapter<BatteryAdder> implements BatteryAdder {
public class BatteryAdderAdapter extends AbstractInjectionAdderAdapter<Battery, BatteryAdder> implements BatteryAdder {

BatteryAdderAdapter(final BatteryAdder delegate, final MergingViewIndex index) {
super(delegate, index);
Expand Down
Loading