Skip to content

Commit

Permalink
#274: Changed mathematical ValueExpression operand names to their cor…
Browse files Browse the repository at this point in the history
…rect ones.
  • Loading branch information
jvdb committed Dec 21, 2018
1 parent a8d996e commit 7cb581b
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@
*/
public class Add extends BinaryValueExpression {

public Add(final ValueExpression left, final ValueExpression right) {
super(left, right);
public Add(final ValueExpression augends, final ValueExpression addends) {
super(augends, addends);
}

@Override
public Optional<Value> eval(final Value leftValue, final Value rightValue, final ParseState parseState, final Encoding encoding) {
return Optional.of(ConstantFactory.createFromNumeric(leftValue.asNumeric().add(rightValue.asNumeric()), encoding));
public Optional<Value> eval(final Value augend, final Value addend, final ParseState parseState, final Encoding encoding) {
return Optional.of(ConstantFactory.createFromNumeric(augend.asNumeric().add(addend.asNumeric()), encoding));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,21 @@
/**
* A {@link BinaryValueExpression} that implements integer division.
* <p>
* If one of the values resulting from evaluating <code>right</code> is equal
* If one of the values resulting from evaluating <code>divisors</code> is equal
* to zero, the associated result will be empty.
*/
public class Div extends BinaryValueExpression {

public Div(final ValueExpression left, final ValueExpression right) {
super(left, right);
public Div(final ValueExpression dividends, final ValueExpression divisors) {
super(dividends, divisors);
}

@Override
public Optional<Value> eval(final Value leftValue, final Value rightValue, final ParseState parseState, final Encoding encoding) {
if (rightValue.asNumeric().equals(ZERO)) {
public Optional<Value> eval(final Value dividend, final Value divisor, final ParseState parseState, final Encoding encoding) {
if (divisor.asNumeric().equals(ZERO)) {
return Optional.empty();
}
return Optional.of(ConstantFactory.createFromNumeric(leftValue.asNumeric().divide(rightValue.asNumeric()), encoding));
return Optional.of(ConstantFactory.createFromNumeric(dividend.asNumeric().divide(divisor.asNumeric()), encoding));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,21 @@
/**
* A {@link BinaryValueExpression} that implements the modulo operation.
* <p>
* If one of the values resulting from evaluating <code>right</code> is equal
* If one of the values resulting from evaluating <code>divisors</code> is equal
* to or small than zero, the associated result will be empty.
*/
public class Mod extends BinaryValueExpression {

public Mod(final ValueExpression left, final ValueExpression right) {
super(left, right);
public Mod(final ValueExpression dividends, final ValueExpression divisors) {
super(dividends, divisors);
}

@Override
public Optional<Value> eval(final Value leftValue, final Value rightValue, final ParseState parseState, final Encoding encoding) {
if (rightValue.asNumeric().compareTo(ZERO) <= 0) {
public Optional<Value> eval(final Value dividend, final Value divisor, final ParseState parseState, final Encoding encoding) {
if (divisor.asNumeric().compareTo(ZERO) <= 0) {
return Optional.empty();
}
return Optional.of(ConstantFactory.createFromNumeric(leftValue.asNumeric().mod(rightValue.asNumeric()), encoding));
return Optional.of(ConstantFactory.createFromNumeric(dividend.asNumeric().mod(divisor.asNumeric()), encoding));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@
*/
public class Mul extends BinaryValueExpression {

public Mul(final ValueExpression left, final ValueExpression right) {
super(left, right);
public Mul(final ValueExpression multipliers, final ValueExpression multiplicands) {
super(multipliers, multiplicands);
}

@Override
public Optional<Value> eval(final Value leftValue, final Value rightValue, final ParseState parseState, final Encoding encoding) {
return Optional.of(ConstantFactory.createFromNumeric(leftValue.asNumeric().multiply(rightValue.asNumeric()), encoding));
public Optional<Value> eval(final Value multiplier, final Value multiplicand, final ParseState parseState, final Encoding encoding) {
return Optional.of(ConstantFactory.createFromNumeric(multiplier.asNumeric().multiply(multiplicand.asNumeric()), encoding));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@
*/
public class Sub extends BinaryValueExpression {

public Sub(final ValueExpression left, final ValueExpression right) {
super(left, right);
public Sub(final ValueExpression minuends, final ValueExpression subtrahends) {
super(minuends, subtrahends);
}

@Override
public Optional<Value> eval(final Value leftValue, final Value rightValue, final ParseState parseState, final Encoding encoding) {
return Optional.of(ConstantFactory.createFromNumeric(leftValue.asNumeric().subtract(rightValue.asNumeric()), encoding));
public Optional<Value> eval(final Value minuend, final Value subtrahend, final ParseState parseState, final Encoding encoding) {
return Optional.of(ConstantFactory.createFromNumeric(minuend.asNumeric().subtract(subtrahend.asNumeric()), encoding));
}

}

0 comments on commit 7cb581b

Please sign in to comment.