Simplify formula operation interfaces.

This commit releases the BinaryOperation and UnaryOperation interfaces
of the `formula` package from their `java.util.function` supertypes and
redeclares the previously inherited functions directly in the operation
interfaces, but also reifies them by explicitly using primitive doubles
instead of generics and wrapper classes. Doing so does not change the
functionality or any other code at all, but it makes the interfaces much
"stronger", since they no longer need to consider `null` values, which
they didn't actually take into account anyway. This fixes a warning in
Visual Studio Code (not sure how to get the same warning in IntelliJ)
about the operator registrations in the default formula environment
factory method being unsafe.
This commit is contained in:
Andreas Troelsen 2024-01-01 19:39:59 +01:00
parent e5ffe169a1
commit d8fdbb80c0
2 changed files with 8 additions and 6 deletions

View File

@ -1,7 +1,8 @@
package com.garbagemule.MobArena.formula;
import java.util.function.BiFunction;
@FunctionalInterface
public interface BinaryOperation extends BiFunction<Double, Double, Double> {
public interface BinaryOperation {
double apply(double left, double right);
}

View File

@ -1,7 +1,8 @@
package com.garbagemule.MobArena.formula;
import java.util.function.Function;
@FunctionalInterface
public interface UnaryOperation extends Function<Double, Double> {
public interface UnaryOperation {
double apply(double value);
}