Constrain.java 1019 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package holeg.model;
  2. import java.util.function.Predicate;
  3. public class Constrain {
  4. /**
  5. * Flexibility should be offered when Element is active.
  6. */
  7. public static Predicate<Flexibility> onConstrain = f -> f.getElement().active;
  8. /**
  9. * Flexibility should be offered when Element is inactive.
  10. */
  11. public static Predicate<Flexibility> offConstrain = f -> !f.getElement().active;
  12. private final Predicate<Flexibility> constrainFunction;
  13. private final String name;
  14. public Constrain(Predicate<Flexibility> constrainFunction, String name) {
  15. this.constrainFunction = constrainFunction;
  16. this.name = name;
  17. }
  18. //Example Constrains:
  19. public static Constrain createOnConstrain() {
  20. return new Constrain(onConstrain, "onConstrain");
  21. }
  22. public static Constrain createOffConstrain() {
  23. return new Constrain(offConstrain, "offConstrain");
  24. }
  25. public Predicate<Flexibility> getConstrainFunction() {
  26. return constrainFunction;
  27. }
  28. public String getName() {
  29. return name;
  30. }
  31. }