Starting simplification
This commit is contained in:
@@ -1,7 +0,0 @@
|
||||
package sh.okx.rankup.requirements;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface Operation {
|
||||
boolean check(List<Boolean> booleans);
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package sh.okx.rankup.requirements;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class OperationRegistry {
|
||||
private Map<String, Operation> operations = new HashMap<>();
|
||||
|
||||
public void addOperation(String name, Operation operation) {
|
||||
operations.put(name.toLowerCase(), operation);
|
||||
}
|
||||
|
||||
public Operation getOperation(String name) {
|
||||
return operations.get(name == null ? "all" : name.toLowerCase());
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
package sh.okx.rankup.requirements;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public abstract class ReducerOperation implements Operation {
|
||||
public abstract boolean check(boolean a, boolean b);
|
||||
|
||||
@Override
|
||||
public boolean check(List<Boolean> booleans) {
|
||||
return booleans.stream().reduce(this::check).orElse(true);
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
package sh.okx.rankup.requirements.operation;
|
||||
|
||||
import sh.okx.rankup.requirements.ReducerOperation;
|
||||
|
||||
public class AllOperation extends ReducerOperation {
|
||||
@Override
|
||||
public boolean check(boolean a, boolean b) {
|
||||
return a && b;
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
package sh.okx.rankup.requirements.operation;
|
||||
|
||||
import sh.okx.rankup.requirements.ReducerOperation;
|
||||
|
||||
public class AnyOperation extends ReducerOperation {
|
||||
@Override
|
||||
public boolean check(boolean a, boolean b) {
|
||||
return a || b;
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
package sh.okx.rankup.requirements.operation;
|
||||
|
||||
import sh.okx.rankup.requirements.ReducerOperation;
|
||||
|
||||
public class NoneOperation extends ReducerOperation {
|
||||
@Override
|
||||
public boolean check(boolean a, boolean b) {
|
||||
return !a && !b;
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
package sh.okx.rankup.requirements.operation;
|
||||
|
||||
import sh.okx.rankup.requirements.ReducerOperation;
|
||||
|
||||
public class OneOperation extends ReducerOperation {
|
||||
@Override
|
||||
public boolean check(boolean a, boolean b) {
|
||||
return (a && !b) || (b && !a);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user