Class Survey


  • public class Survey
    extends Object
    • Method Detail

      • transitTo

        public boolean transitTo​(String label)
        Transit to a specific FlowItem in the flow
        Parameters:
        label - for FlowItem to transition to
        Returns:
        true if transition is allowed, false on back transition config
        Throws:
        IllegalArgumentException - if the label is not part of the flow or when the forward transition has not enough answers
      • transitTo

        public boolean transitTo​(FlowItem<?,​?> target)
        Transit to a specific FlowItem in the flow
        Parameters:
        target - FlowItem to transition to
        Returns:
        true if transition is allowed, false on config of FlowItem.onBack(Condition[])
        Throws:
        IllegalArgumentException - if the label is not part of the flow or when the forward transition has not enough answers (will transition to the nearest possible FlowItem)
      • get

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

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

        public <I extends FlowItem<?,​?>> I get​(I type)
        Get a flow item by the given FlowItem
        Parameters:
        type - FlowItem to search in flow
        Returns:
        FlowItem or null when flow doesn't contain the requested item
      • getPrevious

        public FlowItem<?,​?> getPrevious()
        Get previous FlowItem from the flow
        Returns:
        previous FlowItem and null if there is no previous entry
      • getFirst

        public FlowItem<?,​?> getFirst()
        Get first FlowItem of the flow
        Returns:
        first FlowItem of the current flow
      • isEnded

        public boolean isEnded()
        Check if the current flow has ended
        Returns:
        true if there is no next FlowItem
      • getHistory

        public List<HistoryItem> getHistory()
        Get history of answers
        Returns:
        all answers which were given in the context
      • getHistoryJson

        public List<HistoryItemJson> getHistoryJson()
        Get history of answers
        Returns:
        all answers as json format which were given in the context
      • getHistorySize

        public int getHistorySize()
        Get history size
        Returns:
        number of given answers
      • getDurationsMS

        public Map<String,​Long> getDurationsMS()
        Returns times taken between each question useful to track answer times
        Returns:
        times of answered questions
      • autoBackTransition

        public Survey autoBackTransition​(boolean enableAutomatic)
        Defines if back transitions are allowed for non configured back conditions
        Parameters:
        enableAutomatic - true on default
        Returns:
        Survey
      • hasAutoBackTransition

        public boolean hasAutoBackTransition()
        Definition if back transitions are allowed for non configured back conditions
        Returns:
        true on default