mirror of
https://github.com/garbagemule/MobArena.git
synced 2024-11-22 10:36:00 +01:00
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:
parent
e5ffe169a1
commit
d8fdbb80c0
@ -1,7 +1,8 @@
|
|||||||
package com.garbagemule.MobArena.formula;
|
package com.garbagemule.MobArena.formula;
|
||||||
|
|
||||||
import java.util.function.BiFunction;
|
|
||||||
|
|
||||||
@FunctionalInterface
|
@FunctionalInterface
|
||||||
public interface BinaryOperation extends BiFunction<Double, Double, Double> {
|
public interface BinaryOperation {
|
||||||
|
|
||||||
|
double apply(double left, double right);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
package com.garbagemule.MobArena.formula;
|
package com.garbagemule.MobArena.formula;
|
||||||
|
|
||||||
import java.util.function.Function;
|
|
||||||
|
|
||||||
@FunctionalInterface
|
@FunctionalInterface
|
||||||
public interface UnaryOperation extends Function<Double, Double> {
|
public interface UnaryOperation {
|
||||||
|
|
||||||
|
double apply(double value);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user