add new Any iotapredicate.
This commit is contained in:
parent
f9723bbb8c
commit
b50d12464a
2 changed files with 23 additions and 1 deletions
|
@ -3,6 +3,8 @@ package at.petrak.hexcasting.api.casting.arithmetic.predicates;
|
|||
import at.petrak.hexcasting.api.casting.iota.Iota;
|
||||
import at.petrak.hexcasting.api.casting.iota.IotaType;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Used to determine whether a given iota is an acceptable type for the operator that is storing this. It must be strictly a function
|
||||
* of the passed Iota's IotaType, or the caching done by ArithmeticEngine will be invalid.
|
||||
|
@ -18,6 +20,14 @@ public interface IotaPredicate {
|
|||
return new Or(left, right);
|
||||
}
|
||||
|
||||
static IotaPredicate any(IotaPredicate... any) {
|
||||
return new Any(any);
|
||||
}
|
||||
|
||||
static IotaPredicate any(List<IotaPredicate> any) {
|
||||
return new Any(any.toArray(IotaPredicate[]::new));
|
||||
}
|
||||
|
||||
/**
|
||||
* The resulting IotaPredicate returns true if the given iota's type is type.
|
||||
*/
|
||||
|
@ -32,6 +42,18 @@ public interface IotaPredicate {
|
|||
}
|
||||
}
|
||||
|
||||
record Any(IotaPredicate[] any) implements IotaPredicate {
|
||||
|
||||
@Override
|
||||
public boolean test(Iota iota) {
|
||||
for (var i : any) {
|
||||
if (i.test(iota))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
record OfType(IotaType<?> type) implements IotaPredicate {
|
||||
@Override
|
||||
public boolean test(Iota iota) {
|
||||
|
|
|
@ -10,7 +10,7 @@ jetbrainsAnnotationsVersion=23.0.0
|
|||
|
||||
minecraftVersion=1.20.1
|
||||
kotlinVersion=1.7.20
|
||||
modVersion=0.11.1-3
|
||||
modVersion=0.11.1-4
|
||||
|
||||
paucalVersion=0.6.0
|
||||
patchouliVersion=80
|
||||
|
|
Loading…
Reference in a new issue