Class FieldChangeTrigger<S,​T>

  • Type Parameters:
    S - The source field type
    T - The target field type
    All Implemented Interfaces:
    Function<S,​T>

    public class FieldChangeTrigger<S,​T>
    extends Object
    implements Function<S,​T>
    Models a relation between two entity fields such that, if one field changes, the other may change based on the new value of the first field.
    • Method Detail

      • create

        public static <K,​V> FieldChangeTrigger<K,​V> create​(String fieldName,
                                                                       Function<K,​V> action)
        Creates a field change trigger with just an action.
        Type Parameters:
        K - The source field type
        V - The target field type
        Parameters:
        fieldName - The target field name
        action - The action that will set the target
      • create

        public static <K,​V> FieldChangeTrigger<K,​V> create​(String fieldName,
                                                                       Function<K,​V> action,
                                                                       Predicate<K> condition)
        Creates a field change trigger with an action that will execute based on a condition.
        Type Parameters:
        K - The source field type
        V - The target field type
        Parameters:
        fieldName - The target field name
        action - The action that may set the target
        condition - The condition to check before performing the action
      • getTargetFieldName

        public String getTargetFieldName()
        Returns the target field name
      • canApply

        public boolean canApply​(S input)
      • apply

        public T apply​(S input)
        Specified by:
        apply in interface Function<S,​T>