Class BasePhase
- All Implemented Interfaces:
Phase
- Direct Known Subclasses:
AnalysisPhase
,InputDataPhase
,ReportPhase
,SamplePhase
Base implementation of a phase that takes care of the links between the survey, they phase and the question sets.
-
Field Summary
-
Constructor Summary
ConstructorDescriptionBasePhase
(Survey survey2, Function<BasePhase, List<DefaultQuestionSet2>> constructor, BiFunction<IncrementalBuildState, Question, BackingData> noFunction) -
Method Summary
Modifier and TypeMethodDescriptionprotected QuestionSet
buildQuestionSet
(IncrementalBuildState buildState) protected List<QuestionSet>
buildQuestionSets
(IncrementalBuildState buildState) protected boolean
builtQuestionsInvalid
(IncrementalBuildState buildState) Determine whether question sets need rebuilding, will always return false if the phase was constructed with a single static question set.boolean
canSkip
(IncrementalBuildState buildState) boolean
contains
(QuestionSet questionSet) getAvailableQuestionSets
(IncrementalBuildState buildState) Default implementation ofPhase.getAvailableQuestionSets(IncrementalBuildState)
that builds a static list of question sets the first time it sees a build state and then filters them based on what's already been answeredgetBackingData
(IncrementalBuildState buildState, Question question) Allows a survey to delegate backing data requests to the phase that served up the questionstatic BasePhase
simple
(Survey survey, String qsId, boolean skippable, Consumer<DefaultQuestionSet2> consumer) Create a BasePhase that wraps a single question set, with no custom backing data provided by the phasestatic BasePhase
simple
(Survey survey, String qsId, boolean skippable, Consumer<DefaultQuestionSet2> consumer, BiFunction<IncrementalBuildState, Question, BackingData> backingDataFunction) Create a BasePhase that wraps a single question setMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface nz.org.riskscape.wizard.survey2.Phase
isComplete
-
Field Details
-
survey
-
skippableQuestionSets
-
builtQuestionSets
-
-
Constructor Details
-
BasePhase
-
BasePhase
public BasePhase(Survey survey2, Function<BasePhase, List<DefaultQuestionSet2>> constructor, BiFunction<IncrementalBuildState, Question, BackingData> noFunction)
-
-
Method Details
-
simple
public static BasePhase simple(Survey survey, String qsId, boolean skippable, Consumer<DefaultQuestionSet2> consumer) Create a BasePhase that wraps a single question set, with no custom backing data provided by the phase
- Parameters:
qsId
- id to assign to the question setskippable
- true if this question set, and thus the entire phase, can be skippedconsumer
- a function that allows you to add questions to the question set that belongs to the phase
-
simple
public static BasePhase simple(Survey survey, String qsId, boolean skippable, Consumer<DefaultQuestionSet2> consumer, BiFunction<IncrementalBuildState, Question, BackingData> backingDataFunction) Create a BasePhase that wraps a single question set
- Parameters:
qsId
- id to assign to the question setskippable
- true if this question set, and thus the entire phase, can be skippedconsumer
- a function that allows you to add questions to the question set that belongs to the phasebackingDataFunction
- a callback for returning per-question backing data
-
getAvailableQuestionSets
Default implementation of
Phase.getAvailableQuestionSets(IncrementalBuildState)
that builds a static list of question sets the first time it sees a build state and then filters them based on what's already been answered- Specified by:
getAvailableQuestionSets
in interfacePhase
-
builtQuestionsInvalid
Determine whether question sets need rebuilding, will always return false if the phase was constructed with a single static question set. Returns true if the given build state doesn't contain the build state (in its stack) that the phase used to build the question sets it already has.
-
buildQuestionSets
-
buildQuestionSet
-
canSkip
-
getBackingData
Description copied from interface:Phase
Allows a survey to delegate backing data requests to the phase that served up the question
- Specified by:
getBackingData
in interfacePhase
-
contains
-
getSurvey
-