From b50d12464a901cb522f32beca6f3749e21e35b8b Mon Sep 17 00:00:00 2001 From: Talia-12 Date: Mon, 10 Jul 2023 00:00:24 +1000 Subject: [PATCH] add new Any iotapredicate. --- .../arithmetic/predicates/IotaPredicate.java | 22 +++++++++++++++++++ gradle.properties | 2 +- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/Common/src/main/java/at/petrak/hexcasting/api/casting/arithmetic/predicates/IotaPredicate.java b/Common/src/main/java/at/petrak/hexcasting/api/casting/arithmetic/predicates/IotaPredicate.java index afc270d5..41d06481 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/casting/arithmetic/predicates/IotaPredicate.java +++ b/Common/src/main/java/at/petrak/hexcasting/api/casting/arithmetic/predicates/IotaPredicate.java @@ -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 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) { diff --git a/gradle.properties b/gradle.properties index d8916a00..b866c025 100644 --- a/gradle.properties +++ b/gradle.properties @@ -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