Add missing 'final' specifiers
This commit is contained in:
parent
21de6349f4
commit
be5ae2d475
@ -62,7 +62,7 @@ public class Division extends FunctionOperator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T accept(FunctionVisitor<T> visitor) {
|
||||
public <T> T accept(final FunctionVisitor<T> visitor) {
|
||||
return visitor.visit(this);
|
||||
}
|
||||
}
|
@ -58,7 +58,7 @@ public class EmptyNumber implements Function {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T accept(FunctionVisitor<T> visitor) {
|
||||
public <T> T accept(final FunctionVisitor<T> visitor) {
|
||||
return visitor.visit(this);
|
||||
}
|
||||
|
||||
|
@ -584,7 +584,7 @@ public class Expression extends FunctionSingle {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T accept(FunctionVisitor<T> visitor) {
|
||||
public <T> T accept(final FunctionVisitor<T> visitor) {
|
||||
return visitor.visit(this);
|
||||
}
|
||||
|
||||
|
@ -63,7 +63,7 @@ public class Joke implements Function {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T accept(FunctionVisitor<T> visitor) {
|
||||
public <T> T accept(final FunctionVisitor<T> visitor) {
|
||||
return visitor.visit(this);
|
||||
}
|
||||
|
||||
|
@ -57,7 +57,7 @@ public class Logarithm extends FunctionOperator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T accept(FunctionVisitor<T> visitor) {
|
||||
public <T> T accept(final FunctionVisitor<T> visitor) {
|
||||
return visitor.visit(this);
|
||||
}
|
||||
|
||||
|
@ -85,7 +85,7 @@ public class Multiplication extends FunctionOperator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T accept(FunctionVisitor<T> visitor) {
|
||||
public <T> T accept(final FunctionVisitor<T> visitor) {
|
||||
return visitor.visit(this);
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,7 @@ public class Negative extends FunctionSingle {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T accept(FunctionVisitor<T> visitor) {
|
||||
public <T> T accept(final FunctionVisitor<T> visitor) {
|
||||
return visitor.visit(this);
|
||||
}
|
||||
}
|
||||
|
@ -275,7 +275,7 @@ public class Number implements Function {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T accept(FunctionVisitor<T> visitor) {
|
||||
public <T> T accept(final FunctionVisitor<T> visitor) {
|
||||
return visitor.visit(this);
|
||||
}
|
||||
|
||||
|
@ -53,7 +53,7 @@ public class Power extends FunctionOperator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T accept(FunctionVisitor<T> visitor) {
|
||||
public <T> T accept(final FunctionVisitor<T> visitor) {
|
||||
return visitor.visit(this);
|
||||
}
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ public class Root extends FunctionOperator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T accept(FunctionVisitor<T> visitor) {
|
||||
public <T> T accept(final FunctionVisitor<T> visitor) {
|
||||
return visitor.visit(this);
|
||||
}
|
||||
|
||||
|
@ -50,7 +50,7 @@ public class RootSquare extends FunctionOperator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T accept(FunctionVisitor<T> visitor) {
|
||||
public <T> T accept(final FunctionVisitor<T> visitor) {
|
||||
return visitor.visit(this);
|
||||
}
|
||||
|
||||
|
@ -41,7 +41,7 @@ public class Subtraction extends FunctionOperator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T accept(FunctionVisitor<T> visitor) {
|
||||
public <T> T accept(final FunctionVisitor<T> visitor) {
|
||||
return visitor.visit(this);
|
||||
}
|
||||
|
||||
|
@ -45,7 +45,7 @@ public class Sum extends FunctionOperator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T accept(FunctionVisitor<T> visitor) {
|
||||
public <T> T accept(final FunctionVisitor<T> visitor) {
|
||||
return visitor.visit(this);
|
||||
}
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ public class SumSubtraction extends FunctionOperator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T accept(FunctionVisitor<T> visitor) {
|
||||
public <T> T accept(final FunctionVisitor<T> visitor) {
|
||||
return visitor.visit(this);
|
||||
}
|
||||
|
||||
|
@ -60,7 +60,7 @@ public class Undefined implements Function {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T accept(FunctionVisitor<T> visitor) {
|
||||
public <T> T accept(final FunctionVisitor<T> visitor) {
|
||||
return visitor.visit(this);
|
||||
}
|
||||
|
||||
|
@ -133,7 +133,7 @@ public class Variable implements Function {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T accept(FunctionVisitor<T> visitor) {
|
||||
public <T> T accept(final FunctionVisitor<T> visitor) {
|
||||
return visitor.visit(this);
|
||||
}
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ public class Equation extends FunctionOperator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T accept(FunctionVisitor<T> visitor) {
|
||||
public <T> T accept(final FunctionVisitor<T> visitor) {
|
||||
return visitor.visit(this);
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,7 @@ public class EquationsSystem extends FunctionDynamic {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T accept(FunctionVisitor<T> visitor) {
|
||||
public <T> T accept(final FunctionVisitor<T> visitor) {
|
||||
return visitor.visit(this);
|
||||
}
|
||||
|
||||
|
@ -36,7 +36,7 @@ public class EquationsSystemPart extends FunctionSingle {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T accept(FunctionVisitor<T> visitor) {
|
||||
public <T> T accept(final FunctionVisitor<T> visitor) {
|
||||
return visitor.visit(this);
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,7 @@ public class ArcCosine extends FunctionSingle {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T accept(FunctionVisitor<T> visitor) {
|
||||
public <T> T accept(final FunctionVisitor<T> visitor) {
|
||||
return visitor.visit(this);
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,7 @@ public class ArcSine extends FunctionSingle {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T accept(FunctionVisitor<T> visitor) {
|
||||
public <T> T accept(final FunctionVisitor<T> visitor) {
|
||||
return visitor.visit(this);
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,7 @@ public class ArcTangent extends FunctionSingle {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T accept(FunctionVisitor<T> visitor) {
|
||||
public <T> T accept(final FunctionVisitor<T> visitor) {
|
||||
return visitor.visit(this);
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,7 @@ public class Cosine extends FunctionSingle {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T accept(FunctionVisitor<T> visitor) {
|
||||
public <T> T accept(final FunctionVisitor<T> visitor) {
|
||||
return visitor.visit(this);
|
||||
}
|
||||
|
||||
|
@ -53,7 +53,7 @@ public class Sine extends FunctionSingle {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T accept(FunctionVisitor<T> visitor) {
|
||||
public <T> T accept(final FunctionVisitor<T> visitor) {
|
||||
return visitor.visit(this);
|
||||
}
|
||||
|
||||
|
@ -39,7 +39,7 @@ public class Tangent extends FunctionSingle {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T accept(FunctionVisitor<T> visitor) {
|
||||
public <T> T accept(final FunctionVisitor<T> visitor) {
|
||||
return visitor.visit(this);
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,7 @@ import java.util.Optional;
|
||||
*/
|
||||
public abstract class VisitorPattern implements Pattern, FunctionVisitor<Optional<Map<String, Function>>> {
|
||||
@Override
|
||||
public Optional<Map<String, Function>> match(Function function) {
|
||||
public Optional<Map<String, Function>> match(final Function function) {
|
||||
return function.accept(this);
|
||||
}
|
||||
|
||||
@ -33,20 +33,20 @@ public abstract class VisitorPattern implements Pattern, FunctionVisitor<Optiona
|
||||
* non-equal sub-functions in the two matches.
|
||||
*/
|
||||
protected Optional<Map<String, Function>> mergeMatches(
|
||||
Map<String, Function> match1,
|
||||
Map<String, Function> match2
|
||||
final Map<String, Function> match1,
|
||||
final Map<String, Function> match2
|
||||
) {
|
||||
if (!checkSubFunctionEquality(match1, match2)) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
Map<String, Function> merged = new HashMap<>();
|
||||
final Map<String, Function> merged = new HashMap<>();
|
||||
merged.putAll(match1);
|
||||
merged.putAll(match2);
|
||||
return Optional.of(merged);
|
||||
}
|
||||
|
||||
private boolean checkSubFunctionEquality(Map<String, Function> match1, Map<String, Function> match2) {
|
||||
private boolean checkSubFunctionEquality(final Map<String, Function> match1, final Map<String, Function> match2) {
|
||||
for (Map.Entry<String, Function> leftSubFunction : match1.entrySet()) {
|
||||
final String key = leftSubFunction.getKey();
|
||||
if (match2.containsKey(key)
|
||||
@ -58,127 +58,127 @@ public abstract class VisitorPattern implements Pattern, FunctionVisitor<Optiona
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Map<String, Function>> visit(ArcCosine arcCosine) {
|
||||
public Optional<Map<String, Function>> visit(final ArcCosine arcCosine) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Map<String, Function>> visit(ArcSine arcSine) {
|
||||
public Optional<Map<String, Function>> visit(final ArcSine arcSine) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Map<String, Function>> visit(ArcTangent arcTangent) {
|
||||
public Optional<Map<String, Function>> visit(final ArcTangent arcTangent) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Map<String, Function>> visit(Cosine cosine) {
|
||||
public Optional<Map<String, Function>> visit(final Cosine cosine) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Map<String, Function>> visit(Division division) {
|
||||
public Optional<Map<String, Function>> visit(final Division division) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Map<String, Function>> visit(EmptyNumber emptyNumber) {
|
||||
public Optional<Map<String, Function>> visit(final EmptyNumber emptyNumber) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Map<String, Function>> visit(Equation equation) {
|
||||
public Optional<Map<String, Function>> visit(final Equation equation) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Map<String, Function>> visit(EquationsSystem equationsSystem) {
|
||||
public Optional<Map<String, Function>> visit(final EquationsSystem equationsSystem) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Map<String, Function>> visit(EquationsSystemPart equationsSystemPart) {
|
||||
public Optional<Map<String, Function>> visit(final EquationsSystemPart equationsSystemPart) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Map<String, Function>> visit(Expression expression) {
|
||||
public Optional<Map<String, Function>> visit(final Expression expression) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Map<String, Function>> visit(Joke joke) {
|
||||
public Optional<Map<String, Function>> visit(final Joke joke) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Map<String, Function>> visit(Logarithm logarithm) {
|
||||
public Optional<Map<String, Function>> visit(final Logarithm logarithm) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Map<String, Function>> visit(Multiplication multiplication) {
|
||||
public Optional<Map<String, Function>> visit(final Multiplication multiplication) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Map<String, Function>> visit(Negative negative) {
|
||||
public Optional<Map<String, Function>> visit(final Negative negative) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Map<String, Function>> visit(Number number) {
|
||||
public Optional<Map<String, Function>> visit(final Number number) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Map<String, Function>> visit(Power power) {
|
||||
public Optional<Map<String, Function>> visit(final Power power) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Map<String, Function>> visit(Root root) {
|
||||
public Optional<Map<String, Function>> visit(final Root root) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Map<String, Function>> visit(RootSquare rootSquare) {
|
||||
public Optional<Map<String, Function>> visit(final RootSquare rootSquare) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Map<String, Function>> visit(Sine sine) {
|
||||
public Optional<Map<String, Function>> visit(final Sine sine) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Map<String, Function>> visit(Subtraction subtraction) {
|
||||
public Optional<Map<String, Function>> visit(final Subtraction subtraction) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Map<String, Function>> visit(SumSubtraction sumSubtraction) {
|
||||
public Optional<Map<String, Function>> visit(final SumSubtraction sumSubtraction) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Map<String, Function>> visit(Sum sum) {
|
||||
public Optional<Map<String, Function>> visit(final Sum sum) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Map<String, Function>> visit(Tangent tangent) {
|
||||
public Optional<Map<String, Function>> visit(final Tangent tangent) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Map<String, Function>> visit(Undefined undefined) {
|
||||
public Optional<Map<String, Function>> visit(final Undefined undefined) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Map<String, Function>> visit(Variable variable) {
|
||||
public Optional<Map<String, Function>> visit(final Variable variable) {
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
|
@ -15,17 +15,17 @@ import java.util.Optional;
|
||||
public class NegativePattern extends VisitorPattern {
|
||||
private final Pattern inner;
|
||||
|
||||
public NegativePattern(Pattern inner) {
|
||||
public NegativePattern(final Pattern inner) {
|
||||
this.inner = inner;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Map<String, Function>> visit(Negative negative) {
|
||||
public Optional<Map<String, Function>> visit(final Negative negative) {
|
||||
return inner.match(negative.getParameter());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Function replace(MathContext mathContext, Map<String, Function> subFunctions) {
|
||||
public Function replace(final MathContext mathContext, final Map<String, Function> subFunctions) {
|
||||
return new Negative(
|
||||
mathContext,
|
||||
inner.replace(mathContext, subFunctions)
|
||||
|
@ -16,12 +16,12 @@ import java.util.Optional;
|
||||
public class NumberPattern extends VisitorPattern {
|
||||
private final BigDecimal value;
|
||||
|
||||
public NumberPattern(BigDecimal value) {
|
||||
public NumberPattern(final BigDecimal value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Map<String, Function>> visit(Number number) {
|
||||
public Optional<Map<String, Function>> visit(final Number number) {
|
||||
if (number.getTerm().compareTo(value) == 0) {
|
||||
return Optional.of(new HashMap<>());
|
||||
} else {
|
||||
@ -30,7 +30,7 @@ public class NumberPattern extends VisitorPattern {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Function replace(MathContext mathContext, Map<String, Function> subFunctions) {
|
||||
public Function replace(final MathContext mathContext, final Map<String, Function> subFunctions) {
|
||||
return new Number(mathContext, value);
|
||||
}
|
||||
}
|
||||
|
@ -14,19 +14,19 @@ import java.util.Optional;
|
||||
public class SubFunctionPattern implements Pattern {
|
||||
private final String name;
|
||||
|
||||
public SubFunctionPattern(String name) {
|
||||
public SubFunctionPattern(final String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Map<String, Function>> match(Function function) {
|
||||
HashMap<String, Function> subFunctions = new HashMap<>();
|
||||
public Optional<Map<String, Function>> match(final Function function) {
|
||||
final HashMap<String, Function> subFunctions = new HashMap<>();
|
||||
subFunctions.put(name, function);
|
||||
return Optional.of(subFunctions);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Function replace(MathContext mathContext, Map<String, Function> subFunctions) {
|
||||
public Function replace(final MathContext mathContext, final Map<String, Function> subFunctions) {
|
||||
return subFunctions.get(name);
|
||||
}
|
||||
}
|
||||
|
@ -16,13 +16,13 @@ public class SumPattern extends VisitorPattern {
|
||||
private final Pattern left;
|
||||
private final Pattern right;
|
||||
|
||||
public SumPattern(Pattern left, Pattern right) {
|
||||
public SumPattern(final Pattern left, final Pattern right) {
|
||||
this.left = left;
|
||||
this.right = right;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Map<String, Function>> visit(Sum sum) {
|
||||
public Optional<Map<String, Function>> visit(final Sum sum) {
|
||||
return left.match(sum.getParameter1())
|
||||
.flatMap(leftMatch -> right.match(sum.getParameter2())
|
||||
.flatMap(rightMatch -> mergeMatches(leftMatch, rightMatch))
|
||||
@ -30,7 +30,7 @@ public class SumPattern extends VisitorPattern {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Function replace(MathContext mathContext, Map<String, Function> subFunctions) {
|
||||
public Function replace(final MathContext mathContext, final Map<String, Function> subFunctions) {
|
||||
return new Sum(
|
||||
mathContext,
|
||||
left.replace(mathContext, subFunctions),
|
||||
|
Loading…
Reference in New Issue
Block a user