Package berlin.yuna.survey.model.types
Class FlowItem<T,C extends FlowItem<T,C>>
java.lang.Object
berlin.yuna.survey.model.types.FlowItem<T,C>
- Type Parameters:
T
- Item typeC
- Self item class
- All Implemented Interfaces:
Comparable<FlowItem<?,
?>>
- Direct Known Subclasses:
Question
,QuestionBool
,QuestionInt
,QuestionList
,QuestionLong
public abstract class FlowItem<T,C extends FlowItem<T,C>>
extends Object
implements Comparable<FlowItem<?,?>>
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
Returns nextFlowItem
which is configured for a back transitionint
diagram()
Prepares diagram rendererboolean
find
(I search) SearchFlowItem
in current flowConverts json to answer objectget
(I type) Get a flow item by the givenFlowItem
Get a flow item by the givenenum
Get a flow item by the givenString
<I extends FlowItem<?,
?>>
IgetOrElse
(I type, I fallback) Get a flow item by thistype
FlowItem<?,
?> Get a flow item by thisenum
FlowItem<?,
?> Get a flow item by thisString
int
hashCode()
label()
boolean
match
(HistoryItemBase<?> answer) Defines a back transition oftargets()
Defines a back transition target oftargets()
Defines a back transition oftargets()
parents()
Returns aSet
with all configured targetsparse
(ContextExchange context) (Optional) Input converter to handle the answer - used to solveparseAndApply(ContextExchange, Function)
parseAndAnswer
(ContextExchange context) Returns nextFlowItem
which is configured for a back transitionprotected <R> Optional<R>
parseAndApply
(ContextExchange context, Function<T, Optional<R>> function) Returns nextFlowItem
which is configured for a back transitionparseAndRevert
(ContextExchange context) Reverts configured actions for a back transitionsReturns nextFlowItem
which is configured for a back transitionroutes()
Defines a transition target oftargets()
A previous target without conditions will be overwrittenDefines a transition target oftargets()
Defines a transition target oftargets()
Defines a transition target oftargets()
<I extends FlowItem<?,
?>>
ItargetGet
(I target) Defines a transition target oftargets()
<I extends FlowItem<?,
?>>
IDefines a transition target oftargets()
<I extends FlowItem<?,
?>>
IDefines a transition target oftargets()
targets()
Returns aSet
with all configured targetsReturns aSet
with all configured targetsConverts answer object to jsontoString()
-
Constructor Details
-
FlowItem
-
-
Method Details
-
get
Get a flow item by the givenenum
- Parameters:
label
- Thelabel
to search in flow- Returns:
Optional<FlowItem>
orOptional.empty()
when flow doesn't contain the requested item
-
get
Get a flow item by the givenString
- Parameters:
label
- Thelabel
to search in flow- Returns:
Optional<FlowItem>
orOptional.empty()
when flow doesn't contain the requested item
-
get
Get a flow item by the givenFlowItem
- Parameters:
type
-FlowItem
to search in flow- Returns:
Optional<FlowItem>
orOptional.empty()
when flow doesn't contain the requested item
-
getOrElse
Get a flow item by thisString
-
getOrElse
Get a flow item by thisenum
-
getOrElse
Get a flow item by thistype
-
target
Defines a transition target oftargets()
A previous target without conditions will be overwritten- Parameters:
target
- defines the transition target- Returns:
- the current object
-
target
Defines a transition target oftargets()
- Parameters:
target
- defines the transition targetcondition
-condition
to match. Ontrue
will execute the transition - Conditions can be also used to trigger a process- Returns:
- current object
-
target
Defines a transition target oftargets()
- Parameters:
target
- defines the transition targetcondition
-condition
to match. Ontrue
will execute the transition - Conditions can be also used to trigger a process- Returns:
- current object
-
target
Defines a transition target oftargets()
- Parameters:
target
- defines the transition targetcondition
-condition
to match. Ontrue
will execute the transition - Conditions can be also used to trigger a process- Returns:
- current object
-
targetGet
Defines a transition target oftargets()
- Parameters:
target
- defines the transition target- Returns:
target
object
-
targetGet
Defines a transition target oftargets()
- Parameters:
target
- defines the transition targetcondition
-condition
to match. Ontrue
will execute the transition - Conditions can be also used to trigger a process- Returns:
target
object
-
targetGet
Defines a transition target oftargets()
- Parameters:
target
- defines the transition targetcondition
-condition
to match. Ontrue
will execute the transition - Conditions can be also used to trigger a process- Returns:
target
object
-
targets
Returns aSet
with all configured targets- Returns:
- a set view of all configured
targets
for thisFlowItem
object
-
onBack
Defines a back transition oftargets()
- Parameters:
condition
-condition
to match. Ontrue
will execute the transition - Conditions can be also used to trigger a process- Returns:
- current object
-
onBack
Defines a back transition oftargets()
- Parameters:
conditions
-condition
to match. Ontrue
will execute the transition - Conditions can be also used to trigger a process- Returns:
- current object
-
onBack
Defines a back transition target oftargets()
- Parameters:
conditions
-condition
to match. Ontrue
will execute the transition - Conditions can be also used to trigger a process- Returns:
- current object
-
targetsBack
Returns aSet
with all configured targets- Returns:
- a set view of all configured
targets
for thisFlowItem
object
-
parents
Returns aSet
with all configured targets- Returns:
- a set view of all configured
targets
for thisFlowItem
object
-
parse
(Optional) Input converter to handle the answer - used to solveparseAndApply(ContextExchange, Function)
- Parameters:
context
- input parameter to be parsed for the condition of a configuredRoute
- Returns:
Optional.empty()
to used the default cast and JSON parserparseAndApply(ContextExchange, Function)
-
parseAndAnswer
Returns nextFlowItem
which is configured for a back transition- Parameters:
context
- input parameter- Returns:
- next (
backTransition
)FlowItem
-
parseAndApply
Returns nextFlowItem
which is configured for a back transition- Parameters:
context
- input parameterfunction
- apply after parsing- Returns:
- next (
backTransition
)FlowItem
-
toJson
Converts answer object to json- Parameters:
answer
- to convert to json- Returns:
- input as json format
-
fromJson
Converts json to answer object- Parameters:
answerJson
- json to be converted to object- Returns:
- object from json
-
answer
Returns nextFlowItem
which is configured for a back transition- Parameters:
answer
- input parameter- Returns:
- next (
backTransition
)FlowItem
-
parseAndRevert
Reverts configured actions for a back transitions- Parameters:
context
- input parameter- Returns:
true
if transition is allowed (empty if no transition is configured)
-
revert
Returns nextFlowItem
which is configured for a back transition- Parameters:
answer
- input parameter- Returns:
true
if transition is allowed (empty if no transition is configured)
-
label
- Returns:
- label
-
match
- Parameters:
answer
- input for check- Returns:
true
ifHistoryItem
relates to the currentFlowItem
-
transitions
- Returns:
- a copy of configured routes
-
routes
- Returns:
- a copy of configured routes
-
diagram
Prepares diagram renderer- Returns:
DiagramExporter
renderer
-
find
SearchFlowItem
in current flow- Parameters:
search
- type to search in flow- Returns:
Optional.empty()
of not found
-
addParent
-
equals
-
hashCode
public int hashCode() -
toString
-
compareTo
- Specified by:
compareTo
in interfaceComparable<T>
-