Package nz.org.riskscape.wizard.survey2
Class BasePhase
java.lang.Object
nz.org.riskscape.wizard.survey2.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
Fields inherited from interface nz.org.riskscape.wizard.survey2.Phase
EMPTY_PHASE
-
Constructor Summary
-
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 answeredboolean
isComplete
(IncrementalBuildState buildState) static BasePhase
simple
(Survey survey, String qsId, boolean skippable, Consumer<DefaultQuestionSet2> consumer) Create a BasePhase that wraps a single question set
-
Field Details
-
survey
-
skippableQuestionSets
-
builtQuestionSets
-
-
Constructor Details
-
BasePhase
-
BasePhase
-
-
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
- 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
-
isComplete
- Returns:
- true if there are no more question sets that can be answered
-
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 -
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
- Returns:
- true if the remaining question sets in this phase can be skipped, or false if they must be answered to move on to the next phase
-
contains
- Returns:
- true if the given question set belongs to this phase. Used by the survey code to track a build state back to a phase
-
getName
-
getSurvey
-