123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- package holeg.model;
- import java.util.function.Predicate;
- import com.google.gson.annotations.Expose;
- public class Constrain {
- private Predicate<Flexibility> constrainFunction;
- private String name;
-
- public Constrain(Predicate<Flexibility> constrainFunction,String name) {
- this.constrainFunction = constrainFunction;
- this.name = name;
- }
-
- public Predicate<Flexibility> getConstrainFunction() {
- return constrainFunction;
- }
- public String getName() {
- return name;
- }
-
-
- //Example Constrains:
- /** Flexibility should be offered when Element is active.*/
- public static Predicate<Flexibility> onConstrain = f -> f.getElement().active;
- /** Flexibility should be offered when Element is inactive.*/
- public static Predicate<Flexibility> offConstrain = f -> !f.getElement().active;
-
- public static Constrain createOnConstrain() {
- return new Constrain( onConstrain, "onConstrain");
- }
- public static Constrain createOffConstrain() {
- return new Constrain( offConstrain, "offConstrain");
- }
-
-
-
- /**
- * TODO(Tom2022-01-25): Delete me ....
- * @return
- */
- public boolean fixJson() {
- if(name.equals("onConstrain")) {
- constrainFunction = onConstrain;
- return false;
- }else if(name.equals("offConstrain")){
- constrainFunction = offConstrain;
- return false;
- }else {
- return false;
- }
- }
- }
|