Package berlin.yuna.survey.logic
Class Survey
java.lang.Object
berlin.yuna.survey.logic.Survey
-
Method Summary
Modifier and TypeMethodDescriptionSolves the currentFlowItem
of the flowSolves the currentFlowItem
of the flowautoBackTransition
(boolean enableAutomatic) Defines if back transitions are allowed for non configured back conditionsdiagram()
Prepares diagram rendererprotected FlowItem<?,
?> findLast
(LinkedList<HistoryItem> historySorted) FlowItem<?,
?> get()
Get currentFlowItem
of the flow<I extends FlowItem<?,
?>>
Iget
(I type) Get a flow item by the givenFlowItem
FlowItem<?,
?> Get a flow item by the givenenum
To avoid cast its recommended to useFlowItem.get(FlowItem)
FlowItem<?,
?> Get a flow item by the givenString
To avoid cast its recommended to useFlowItem.get(FlowItem)
Returns times taken between each question useful to track answer timesFlowItem<?,
?> getFirst()
Get firstFlowItem
of the flowGet history of answersGet history of answersint
Get history sizeFlowItem<?,
?> Get previousFlowItem
from the flowboolean
Definition if back transitions are allowed for non configured back conditionsstatic Survey
Starts new SurveyCtxstatic Survey
init
(FlowItem<?, ?> flowStart, Iterable<? extends HistoryItemBase<?>> history) boolean
isEnded()
Check if the current flow has endedboolean
Transit to a specificFlowItem
in the flowboolean
Transit to a specificFlowItem
in the flowboolean
Transit to a specificFlowItem
in the flowboolean
Transit to a specificFlowItem
in the flow
-
Method Details
-
init
Starts new SurveyCtx- Parameters:
flowStart
- start item of the flow- Returns:
Survey
- Throws:
IllegalStateException
- onnull
-
init
- Parameters:
flowStart
- start item of the flowhistory
- should not be empty asSurvey
needs a start item- Returns:
Survey
- Throws:
IllegalStateException
- when thehistory
is empty or has no validFlowItem
-
transitTo
Transit to a specificFlowItem
in the flow- Parameters:
label
- forFlowItem
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
Transit to a specificFlowItem
in the flow- Parameters:
label
- forFlowItem
to transition tocontext
- sets the context onContextExchange
which is used atFlowItem.parse(ContextExchange)
- 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
Transit to a specificFlowItem
in the flow- Parameters:
target
-FlowItem
to transition to- Returns:
true
if transition is allowed,false
on config ofFlowItem.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 possibleFlowItem
)
-
transitTo
Transit to a specificFlowItem
in the flow- Parameters:
target
-FlowItem
to transition tocontext
- sets the context onContextExchange
which is used atFlowItem.parse(ContextExchange)
- Returns:
true
if transition is allowed,false
on config ofFlowItem.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 possibleFlowItem
)
-
get
Get currentFlowItem
of the flow- Returns:
FlowItem
of the current flow
-
get
Get a flow item by the givenString
To avoid cast its recommended to useFlowItem.get(FlowItem)
-
get
Get a flow item by the givenenum
To avoid cast its recommended to useFlowItem.get(FlowItem)
- Parameters:
label
- Thelabel
to search in flow- Returns:
FlowItem
ornull
when flow doesn't contain the requested item
-
get
Get a flow item by the givenFlowItem
-
getPrevious
Get previousFlowItem
from the flow- Returns:
- previous
FlowItem
andnull
if there is no previous entry
-
getFirst
Get firstFlowItem
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
Get history of answers- Returns:
- all answers which were given in the context
-
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
-
answer
Solves the currentFlowItem
of the flow -
answer
Solves the currentFlowItem
of the flow- Parameters:
answer
- answer to solve the currentFlowItem
context
- sets the context onContextExchange
which is used atFlowItem.parse(ContextExchange)
- Returns:
Survey
-
getDurationsMS
Returns times taken between each question useful to track answer times- Returns:
- times of answered questions
-
autoBackTransition
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
-
diagram
Prepares diagram renderer- Returns:
DiagramExporter
renderer
-
findLast
-