From 0427ab89f1753a44b30cbc35ce021cbbdc845109 Mon Sep 17 00:00:00 2001 From: Foghrye4 Date: Thu, 10 Aug 2017 18:52:45 +0300 Subject: fix missing source folder --- .../java/gregtech/api/interfaces/ICondition.java | 104 +++++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 src/main/java/gregtech/api/interfaces/ICondition.java (limited to 'src/main/java/gregtech/api/interfaces/ICondition.java') diff --git a/src/main/java/gregtech/api/interfaces/ICondition.java b/src/main/java/gregtech/api/interfaces/ICondition.java new file mode 100644 index 0000000..507315e --- /dev/null +++ b/src/main/java/gregtech/api/interfaces/ICondition.java @@ -0,0 +1,104 @@ +package gregtech.api.interfaces; + +public interface ICondition { + public boolean isTrue(O aObject); + + // Utility Classes for adding relations between Conditions. + + public static class Not implements ICondition { + private final ICondition mCondition; + + public Not(ICondition aCondition) { + mCondition = aCondition; + } + + @Override + public boolean isTrue(O aObject) { + return !mCondition.isTrue(aObject); + } + } + + public static class Or implements ICondition { + private final ICondition[] mConditions; + + public Or(ICondition... aConditions) { + mConditions = aConditions; + } + + @Override + public boolean isTrue(O aObject) { + for (ICondition tCondition : mConditions) if (tCondition.isTrue(aObject)) return true; + return false; + } + } + + public static class Nor implements ICondition { + private final ICondition[] mConditions; + + public Nor(ICondition... aConditions) { + mConditions = aConditions; + } + + @Override + public boolean isTrue(O aObject) { + for (ICondition tCondition : mConditions) if (tCondition.isTrue(aObject)) return false; + return true; + } + } + + public static class And implements ICondition { + private final ICondition[] mConditions; + + public And(ICondition... aConditions) { + mConditions = aConditions; + } + + @Override + public boolean isTrue(O aObject) { + for (ICondition tCondition : mConditions) if (!tCondition.isTrue(aObject)) return false; + return true; + } + } + + public static class Nand implements ICondition { + private final ICondition[] mConditions; + + public Nand(ICondition... aConditions) { + mConditions = aConditions; + } + + @Override + public boolean isTrue(O aObject) { + for (ICondition tCondition : mConditions) if (!tCondition.isTrue(aObject)) return true; + return false; + } + } + + public static class Xor implements ICondition { + private final ICondition mCondition1, mCondition2; + + public Xor(ICondition aCondition1, ICondition aCondition2) { + mCondition1 = aCondition1; + mCondition2 = aCondition2; + } + + @Override + public boolean isTrue(O aObject) { + return mCondition1.isTrue(aObject) != mCondition2.isTrue(aObject); + } + } + + public static class Equal implements ICondition { + private final ICondition mCondition1, mCondition2; + + public Equal(ICondition aCondition1, ICondition aCondition2) { + mCondition1 = aCondition1; + mCondition2 = aCondition2; + } + + @Override + public boolean isTrue(O aObject) { + return mCondition1.isTrue(aObject) == mCondition2.isTrue(aObject); + } + } +} \ No newline at end of file -- cgit v1.2.3