Skip to content

Commit

Permalink
unused methods, to remove class when upgrade version powsybl
Browse files Browse the repository at this point in the history
Signed-off-by: maissa SOUISSI <[email protected]>
  • Loading branch information
souissimai committed Jun 8, 2024
1 parent e4b0995 commit 59b3acd
Showing 1 changed file with 1 addition and 54 deletions.
55 changes: 1 addition & 54 deletions src/main/java/com/powsybl/nad/build/iidm/VoltageLevelFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,8 @@
/**
* @author Maissa Souissi {<maissa.souissi at rte-france.com>}
*/

public class VoltageLevelFilter implements Predicate<VoltageLevel> {
/*
# FIXME: to be removed at next powsybl-ws-dependencies upgrade
*/

protected static final Logger LOGGER = LoggerFactory.getLogger(VoltageLevelFilter.class);

public static final Predicate<VoltageLevel> NO_FILTER = voltageLevel -> true;
Expand All @@ -49,49 +46,11 @@ public boolean test(VoltageLevel voltageLevel) {
return voltageLevels.contains(voltageLevel);
}

public static VoltageLevelFilter createVoltageLevelsFilter(Network network, List<String> voltageLevelIds) {
return createVoltageLevelsDepthFilter(network, voltageLevelIds, 0);
}

public static VoltageLevelFilter createVoltageLevelDepthFilter(Network network, String voltageLevelId, int depth) {
return createVoltageLevelsDepthFilter(network, List.of(voltageLevelId), depth);
}

public static VoltageLevelFilter createVoltageLevelsDepthFilter(Network network, List<String> voltageLevelIds, int depth) {
return createVoltageLevelFilterWithPredicate(network, voltageLevelIds, depth, NO_FILTER);
}

public static VoltageLevelFilter createNominalVoltageLowerBoundFilter(Network network, List<String> voltageLevelIds, double nominalVoltageLowerBound, int depth) {
return createNominalVoltageFilter(network, voltageLevelIds, nominalVoltageLowerBound, Double.MAX_VALUE, depth);
}

public static VoltageLevelFilter createNominalVoltageLowerBoundFilter(Network network, double nominalVoltageLowerBound) {
return createNominalVoltageFilter(network, nominalVoltageLowerBound, Double.MAX_VALUE);
}

public static VoltageLevelFilter createNominalVoltageUpperBoundFilter(Network network, List<String> voltageLevelIds, double nominalVoltageUpperBound, int depth) {
return createNominalVoltageFilter(network, voltageLevelIds, 0, nominalVoltageUpperBound, depth);
}

public static VoltageLevelFilter createNominalVoltageUpperBoundFilter(Network network, double nominalVoltageUpperBound) {
return createNominalVoltageFilter(network, 0, nominalVoltageUpperBound);
}

public static VoltageLevelFilter createNominalVoltageFilter(Network network, List<String> voltageLevelIds,
double nominalVoltageLowerBound, double nominalVoltageUpperBound,
int depth) {
return createVoltageLevelFilterWithPredicate(network, voltageLevelIds, depth, getPredicateFromNominalVoltageBounds(nominalVoltageLowerBound, nominalVoltageUpperBound));
}

public static VoltageLevelFilter createNominalVoltageFilter(Network network, double nominalVoltageLowerBound, double nominalVoltageUpperBound) {
return createNominalVoltageFilterWithPredicate(network, getPredicateFromNominalVoltageBounds(nominalVoltageLowerBound, nominalVoltageUpperBound));
}

private static Predicate<VoltageLevel> getPredicateFromNominalVoltageBounds(double nominalVoltageLowerBound, double nominalVoltageUpperBound) {
checkVoltageBoundValues(nominalVoltageLowerBound, nominalVoltageUpperBound);
return voltageLevel -> voltageLevel.getNominalV() >= nominalVoltageLowerBound && voltageLevel.getNominalV() <= nominalVoltageUpperBound;
}

public static VoltageLevelFilter createVoltageLevelFilterWithPredicate(Network network, List<String> voltageLevelIds, int depth, Predicate<VoltageLevel> voltageLevelPredicate) {
Objects.requireNonNull(network);
Objects.requireNonNull(voltageLevelIds);
Expand All @@ -112,9 +71,6 @@ public static VoltageLevelFilter createVoltageLevelFilterWithPredicate(Network n
return new VoltageLevelFilter(voltageLevels);
}

public static VoltageLevelFilter createNominalVoltageFilterWithPredicate(Network network, Predicate<VoltageLevel> voltageLevelPredicate) {
return new VoltageLevelFilter(network.getVoltageLevelStream().filter(voltageLevelPredicate).collect(Collectors.toSet()));
}

public static Collection<VoltageLevel> getNextDepthVoltageLevels(Network network, List<VoltageLevel> voltageLevels) {
List<String> voltageLevelIds = voltageLevels.stream().map(VoltageLevel::getId).collect(Collectors.toList());
Expand All @@ -138,15 +94,6 @@ private static void traverseVoltageLevels(Set<VoltageLevel> voltageLevelsDepth,
traverseVoltageLevels(nextDepthVoltageLevels, depth - 1, visitedVoltageLevels, predicate);
}

private static void checkVoltageBoundValues(double nominalVoltageLowerBound, double nominalVoltageUpperBound) {
if (nominalVoltageLowerBound < 0 || nominalVoltageUpperBound < 0) {
throw new PowsyblException("Voltage bounds must be positive");
}
if (nominalVoltageLowerBound > nominalVoltageUpperBound) {
throw new PowsyblException("Low bound must be less than or equal to high bound");
}
}

private static class VlVisitor extends DefaultTopologyVisitor {
private final Set<VoltageLevel> nextDepthVoltageLevels;
private final Set<VoltageLevel> visitedVoltageLevels;
Expand Down

0 comments on commit 59b3acd

Please sign in to comment.