Skip to content
This repository has been archived by the owner on May 16, 2018. It is now read-only.

Commit

Permalink
Merge branch 'master' into multistates_test
Browse files Browse the repository at this point in the history
  • Loading branch information
mathbagu committed Aug 28, 2017
2 parents ec99814 + cd6ba24 commit 00cad8b
Show file tree
Hide file tree
Showing 367 changed files with 2,862 additions and 1,712 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,4 @@ public Expression transform(Expression exp) {
printAST(blockStatement);
}
}
}
}
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 class AbstractActionDslLoaderObserver implements ActionDslLoaderObserver {
public class DefaultActionDslLoaderObserver implements ActionDslLoaderObserver {
@Override
public void begin(String dslFile) {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ public interface DslConstants {

String SCRIPT_IS_RUNNING = "scriptIsRunning";

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import java.io.IOException;
import java.io.Reader;
import java.io.UncheckedIOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
Expand All @@ -39,7 +40,7 @@ public List<Contingency> getContingencies(Network network) {
.load(network);
return ImmutableList.copyOf(actionDb.getContingencies());
} catch (IOException e) {
throw new RuntimeException(e);
throw new UncheckedIOException(e);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
/**
* @author Geoffroy Jamgotchian <geoffroy.jamgotchian at rte-france.com>
*/
public abstract class BinaryOperatorNode implements ExpressionNode {
public abstract class AbstractBinaryOperatorNode implements ExpressionNode {

protected final ExpressionNode left;

protected final ExpressionNode right;

protected BinaryOperatorNode(ExpressionNode left, ExpressionNode right) {
protected AbstractBinaryOperatorNode(ExpressionNode left, ExpressionNode right) {
this.left = Objects.requireNonNull(left);
this.right = Objects.requireNonNull(right);
}
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 abstract class LiteralNode implements ExpressionNode {
public abstract class AbstractLiteralNode implements ExpressionNode {

public abstract LiteralType getType();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
/**
* @author Geoffroy Jamgotchian <geoffroy.jamgotchian at rte-france.com>
*/
public abstract class UnaryOperatorNode implements ExpressionNode {
public abstract class AbstractUnaryOperatorNode implements ExpressionNode {

protected final ExpressionNode child;

protected UnaryOperatorNode(ExpressionNode child) {
protected AbstractUnaryOperatorNode(ExpressionNode child) {
this.child = Objects.requireNonNull(child);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
/**
* @author Geoffroy Jamgotchian <geoffroy.jamgotchian at rte-france.com>
*/
public class ArithmeticBinaryOperatorNode extends BinaryOperatorNode {
public class ArithmeticBinaryOperatorNode extends AbstractBinaryOperatorNode {

private final ArithmeticBinaryOperator operator;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
/**
* @author Geoffroy Jamgotchian <geoffroy.jamgotchian at rte-france.com>
*/
public class BigDecimalLiteralNode extends LiteralNode {
public class BigDecimalLiteralNode extends AbstractLiteralNode {

private final BigDecimal value;

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 class BooleanLiteralNode extends LiteralNode {
public class BooleanLiteralNode extends AbstractLiteralNode {

public static final BooleanLiteralNode TRUE = new BooleanLiteralNode(Boolean.TRUE);
public static final BooleanLiteralNode FALSE = new BooleanLiteralNode(Boolean.FALSE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
/**
* @author Geoffroy Jamgotchian <geoffroy.jamgotchian at rte-france.com>
*/
public class ComparisonOperatorNode extends BinaryOperatorNode {
public class ComparisonOperatorNode extends AbstractBinaryOperatorNode {

private final ComparisonOperator operator;

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 class AbstractExpressionVisitor<R, A> implements ExpressionVisitor<R, A> {
public class DefaultExpressionVisitor<R, A> implements ExpressionVisitor<R, A> {
@Override
public R visitComparisonOperator(ComparisonOperatorNode node, A arg) {
node.getLeft().accept(this, arg);
Expand Down Expand Up @@ -38,7 +38,7 @@ public R visitNotOperator(LogicalNotOperator node, A arg) {
}

@Override
public R visitLiteral(LiteralNode node, A arg) {
public R visitLiteral(AbstractLiteralNode node, A arg) {
return null;
}

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 class DoubleLiteralNode extends LiteralNode {
public class DoubleLiteralNode extends AbstractLiteralNode {

private final double value;

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>
*/
public class ExpressionActionTakenLister extends AbstractExpressionVisitor<Void, List<String>> {
public class ExpressionActionTakenLister extends DefaultExpressionVisitor<Void, List<String>> {

public static List<String> list(ExpressionNode root) {
List<String> actionIds = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
/**
* @author Geoffroy Jamgotchian <geoffroy.jamgotchian at rte-france.com>
*/
public class ExpressionEvaluator extends AbstractExpressionVisitor<Object, Void> {
public class ExpressionEvaluator extends DefaultExpressionVisitor<Object, Void> {

private final EvaluationContext context;

Expand All @@ -31,7 +31,7 @@ public static Object evaluate(ExpressionNode node, EvaluationContext context) {
}

@Override
public Object visitLiteral(LiteralNode node, Void arg) {
public Object visitLiteral(AbstractLiteralNode node, Void arg) {
return node.getValue();
}

Expand Down Expand Up @@ -163,7 +163,8 @@ public Object visitContingencyOccurred(ContingencyOccurredNode node, Void arg) {
/**
* Utility class to compare loading on one side of a branch to loading of one side of another branch
*/
private static class BranchAndSide implements Comparable<BranchAndSide> {
private static final class BranchAndSide implements Comparable<BranchAndSide> {

private final TwoTerminalsConnectable branch;
private final TwoTerminalsConnectable.Side side;

Expand All @@ -172,11 +173,11 @@ private BranchAndSide(TwoTerminalsConnectable branch, TwoTerminalsConnectable.Si
this.side = Objects.requireNonNull(side);
}

public TwoTerminalsConnectable getBranch() {
private TwoTerminalsConnectable getBranch() {
return branch;
}

public TwoTerminalsConnectable.Side getSide() {
private TwoTerminalsConnectable.Side getSide() {
return side;
}

Expand Down Expand Up @@ -209,8 +210,8 @@ private static int compare(BranchAndSide branchAndSide1, BranchAndSide branchAnd
c = 1;
} else { // overload1 != null && overload2 != null
// first compare acceptable duration
c = - Integer.compare(overload1.getTemporaryLimit().getAcceptableDuration(),
overload2.getTemporaryLimit().getAcceptableDuration());
c = -Integer.compare(overload1.getTemporaryLimit().getAcceptableDuration(),
overload2.getTemporaryLimit().getAcceptableDuration());
if (c == 0) {
// and then overload based on temporary limit
c = compare(i1 / overload1.getTemporaryLimit().getValue(),
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>
*/
public class ExpressionHelper {
public final class ExpressionHelper {

private ExpressionHelper() {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@
import java.io.IOException;
import java.io.PrintStream;
import java.io.StringWriter;
import java.io.UncheckedIOException;
import java.nio.charset.StandardCharsets;
import java.util.Iterator;
import java.util.Objects;

/**
* @author Geoffroy Jamgotchian <geoffroy.jamgotchian at rte-france.com>
*/
public class ExpressionPrinter extends AbstractExpressionVisitor<Void, Void> {
public class ExpressionPrinter extends DefaultExpressionVisitor<Void, Void> {

private final PrintStream out;

Expand All @@ -30,7 +31,7 @@ public static String toString(ExpressionNode node) {
try {
writer.close();
} catch (IOException e) {
throw new RuntimeException(e);
throw new UncheckedIOException(e);
}
}
return writer.toString();
Expand Down Expand Up @@ -101,7 +102,7 @@ public Void visitNetworkMethod(NetworkMethodNode node, Void arg) {
}

@Override
public Void visitLiteral(LiteralNode node, Void arg) {
public Void visitLiteral(AbstractLiteralNode node, Void arg) {
out.print(node.getValue().toString());
return null;
}
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>
*/
public class ExpressionVariableLister extends AbstractExpressionVisitor<Void, List<NetworkNode>> {
public class ExpressionVariableLister extends DefaultExpressionVisitor<Void, List<NetworkNode>> {

public static List<NetworkNode> list(ExpressionNode root) {
List<NetworkNode> variables = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*/
public interface ExpressionVisitor<R, A> {

R visitLiteral(LiteralNode node, A arg);
R visitLiteral(AbstractLiteralNode node, A arg);

R visitNetworkComponent(NetworkComponentNode node, A arg);

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 class FloatLiteralNode extends LiteralNode {
public class FloatLiteralNode extends AbstractLiteralNode {

private final float value;

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 class IntegerLiteralNode extends LiteralNode {
public class IntegerLiteralNode extends AbstractLiteralNode {

private final int value;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
/**
* @author Geoffroy Jamgotchian <geoffroy.jamgotchian at rte-france.com>
*/
public class LogicalBinaryOperatorNode extends BinaryOperatorNode {
public class LogicalBinaryOperatorNode extends AbstractBinaryOperatorNode {

private final LogicalBinaryOperator operator;

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 class LogicalNotOperator extends UnaryOperatorNode {
public class LogicalNotOperator extends AbstractUnaryOperatorNode {

public LogicalNotOperator(ExpressionNode child) {
super(child);
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 class StringLiteralNode extends LiteralNode {
public class StringLiteralNode extends AbstractLiteralNode {

private final String value;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public void testContigencies() {
try {
actionDb.getContingency("id2");
fail();
} catch (RuntimeException e) {
} catch (RuntimeException ignored) {
}
}

Expand All @@ -57,7 +57,7 @@ public void testActions() {
try {
actionDb.getAction("id2");
fail();
} catch (RuntimeException e) {
} catch (RuntimeException ignored) {
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ private void testInvalid(String id, List<ModificationTask> tasks) {
try {
new Action(id, tasks);
fail();
} catch (NullPointerException exc) {
} catch (NullPointerException ignored) {
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ public void testCondition() throws IOException {
loadAndAssert("true", "true");
loadAndAssert("false", "true && false");
for (String op : Arrays.asList("&&", "||")) {
loadAndAssert("(line('NHV1_NHV2_1').overloaded " + op + " true)", "line('NHV1_NHV2_1').overloaded " + op + " true");
loadAndAssert("(true " + op + " line('NHV1_NHV2_1').overloaded)", "true " + op + " line('NHV1_NHV2_1').overloaded");
loadAndAssert("(line('NHV1_NHV2_1').overloaded " + op + " true)", "line('NHV1_NHV2_1').overloaded " + op + " true");
loadAndAssert("(true " + op + " line('NHV1_NHV2_1').overloaded)", "true " + op + " line('NHV1_NHV2_1').overloaded");
}
loadAndAssert("false", "!true");
loadAndAssert("!(line('NHV1_NHV2_1').overloaded)", "!line('NHV1_NHV2_1').overloaded");
Expand Down Expand Up @@ -347,4 +347,4 @@ public void testActionTakenLister() {
assertTrue(actions.contains("action1"));
assertTrue(actions.contains("action2"));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,4 @@ public void testAutomaticList() throws IOException {
assertEquals(2, contingencies.size());
assertEquals(Sets.newHashSet("NHV1_NHV2_1", "NHV1_NHV2_2"), contingencies.stream().map(Contingency::getId).collect(Collectors.toSet()));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ private void testInvalid(String id, Condition condition, int life, List<String>
try {
new Rule(id, condition, life, actions);
fail();
} catch (RuntimeException e) {
} catch (RuntimeException ignored) {
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
/**
* @author Geoffroy Jamgotchian <geoffroy.jamgotchian at rte-france.com>
*/
public class AbstractLoadFlowActionSimulatorObserver implements LoadFlowActionSimulatorObserver {
public class DefaultLoadFlowActionSimulatorObserver implements LoadFlowActionSimulatorObserver {
@Override
public void beforePreContingencyAnalysis(Network network) {
}
Expand Down
Loading

0 comments on commit 00cad8b

Please sign in to comment.