Class FlowItem<T,​C extends FlowItem<T,​C>>

    • Constructor Detail

      • FlowItem

        public FlowItem​(String label)
    • Method Detail

      • get

        public Optional<FlowItem<?,​?>> get​(Enum<?> label)
        Get a flow item by the given enum
        Parameters:
        label - The label to search in flow
        Returns:
        Optional or Optional.empty() when flow doesn't contain the requested item
      • get

        public Optional<FlowItem<?,​?>> get​(String label)
        Get a flow item by the given String
        Parameters:
        label - The label to search in flow
        Returns:
        Optional or Optional.empty() when flow doesn't contain the requested item
      • getOrElse

        public FlowItem<?,​?> getOrElse​(String label,
                                             FlowItem<?,​?> fallback)
        Get a flow item by this String
        Parameters:
        label - The label to search in flow
        fallback - FlowItem to return if the flow item wasn't found
        Returns:
        FlowItem or fallback when flow doesn't contain the requested item
      • getOrElse

        public FlowItem<?,​?> getOrElse​(Enum<?> label,
                                             FlowItem<?,​?> fallback)
        Get a flow item by this enum
        Parameters:
        label - The label to search in flow
        fallback - FlowItem to return if the flow item wasn't found
        Returns:
        FlowItem or fallback when flow doesn't contain the requested item
      • getOrElse

        public <I extends FlowItem<?,​?>> I getOrElse​(I type,
                                                           I fallback)
        Get a flow item by this type
        Parameters:
        type - The label to search in flow
        fallback - FlowItem to return if the flow item wasn't found
        Returns:
        FlowItem or fallback when flow doesn't contain the requested item
      • target

        public C target​(FlowItem<?,​?> target)
        Defines a transition target of targets() A previous target without conditions will be overwritten
        Parameters:
        target - defines the transition target
        Returns:
        the current object
      • target

        public C target​(FlowItem<?,​?> target,
                        Function<T,​Boolean> condition)
        Defines a transition target of targets()
        Parameters:
        target - defines the transition target
        condition - condition to match. On true will execute the transition - Conditions can be also used to trigger a process
        Returns:
        current object
      • target

        public C target​(FlowItem<?,​?> target,
                        Condition<T> condition)
        Defines a transition target of targets()
        Parameters:
        target - defines the transition target
        condition - condition to match. On true will execute the transition - Conditions can be also used to trigger a process
        Returns:
        current object
      • target

        public C target​(FlowItem<?,​?> target,
                        Class<? extends Condition<?>> condition)
        Defines a transition target of targets()
        Parameters:
        target - defines the transition target
        condition - condition to match. On true will execute the transition - Conditions can be also used to trigger a process
        Returns:
        current object
      • targetGet

        public <I extends FlowItem<?,​?>> I targetGet​(I target)
        Defines a transition target of targets()
        Parameters:
        target - defines the transition target
        Returns:
        target object
      • targetGet

        public <I extends FlowItem<?,​?>> I targetGet​(I target,
                                                           Function<T,​Boolean> condition)
        Defines a transition target of targets()
        Parameters:
        target - defines the transition target
        condition - condition to match. On true will execute the transition - Conditions can be also used to trigger a process
        Returns:
        target object
      • targetGet

        public <I extends FlowItem<?,​?>> I targetGet​(I target,
                                                           Condition<T> condition)
        Defines a transition target of targets()
        Parameters:
        target - defines the transition target
        condition - condition to match. On true will execute the transition - Conditions can be also used to trigger a process
        Returns:
        target object
      • targets

        public Set<FlowItem<?,​?>> targets()
        Returns a Set with all configured targets
        Returns:
        a set view of all configured targets for this FlowItem object
      • onBack

        public C onBack​(Function<T,​Boolean> condition)
        Defines a back transition of targets()
        Parameters:
        condition - condition to match. On true will execute the transition - Conditions can be also used to trigger a process
        Returns:
        current object
      • onBack

        public C onBack​(Condition<T>... conditions)
        Defines a back transition of targets()
        Parameters:
        conditions - condition to match. On true will execute the transition - Conditions can be also used to trigger a process
        Returns:
        current object
      • onBack

        public C onBack​(Class<? extends Condition<?>>... conditions)
        Defines a back transition target of targets()
        Parameters:
        conditions - condition to match. On true will execute the transition - Conditions can be also used to trigger a process
        Returns:
        current object
      • targetsBack

        public Set<FlowItem<?,​?>> targetsBack()
        Returns a Set with all configured targets
        Returns:
        a set view of all configured targets for this FlowItem object
      • parents

        public Set<FlowItem<?,​?>> parents()
        Returns a Set with all configured targets
        Returns:
        a set view of all configured targets for this FlowItem object
      • parseAndAnswer

        public Optional<FlowItem<?,​?>> parseAndAnswer​(ContextExchange context)
        Returns next FlowItem which is configured for a back transition
        Parameters:
        context - input parameter
        Returns:
        next (backTransition) FlowItem
      • parseAndApply

        protected <R> Optional<R> parseAndApply​(ContextExchange context,
                                                Function<T,​Optional<R>> function)
        Returns next FlowItem which is configured for a back transition
        Parameters:
        context - input parameter
        function - apply after parsing
        Returns:
        next (backTransition) FlowItem
      • toJson

        public String toJson​(Object answer)
        Converts answer object to json
        Parameters:
        answer - to convert to json
        Returns:
        input as json format
      • fromJson

        public Optional<T> fromJson​(String answerJson)
        Converts json to answer object
        Parameters:
        answerJson - json to be converted to object
        Returns:
        object from json
      • answer

        public Optional<FlowItem<?,​?>> answer​(T answer)
        Returns next FlowItem which is configured for a back transition
        Parameters:
        answer - input parameter
        Returns:
        next (backTransition) FlowItem
      • parseAndRevert

        public Optional<Boolean> parseAndRevert​(ContextExchange context)
        Reverts configured actions for a back transitions
        Parameters:
        context - input parameter
        Returns:
        true if transition is allowed (empty if no transition is configured)
      • revert

        public Optional<Boolean> revert​(T answer)
        Returns next FlowItem which is configured for a back transition
        Parameters:
        answer - input parameter
        Returns:
        true if transition is allowed (empty if no transition is configured)
      • label

        public String label()
        Returns:
        label
      • transitions

        public TransitionSet<T> transitions()
        Returns:
        a copy of configured routes
      • routes

        public Set<Route<T>> routes()
        Returns:
        a copy of configured routes
      • addParent

        protected void addParent​(FlowItem<?,​?> parent)
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object