Class ConfigParser

java.lang.Object
nz.org.riskscape.wizard.ConfigParser

public class ConfigParser extends Object

Reconstructs a wizard's answers from INI config. This goes through the possible Survey Questions and "answers" them in roughly the same order that an interactive wizard user would have.

Note that we deliberately use this ordered approach rather than just converting all the Survey's Questions into Parameters and binding them all in one go. The reason for doing so is the 'requiredness' of a wizard Parameter/Question is relatively static (i.e. Question.isRequired(), whereas whether a question is applicable/should be asked changes dynamically based on earlier answers (i.e. an answer can unlock follow-up questions). In other words, a straight conversion from Survey to List up-front doesn't make sense because we don't know if a Question/Parameter is truly required until we've started answering questions.

  • Field Details

  • Constructor Details

  • Method Details

    • appendComponent

      public static String appendComponent(String prefix, Object subkey)

      Convenience for returning prefix[subkey]

    • loadConfig

      public nz.org.riskscape.problem.ResultOrProblems<IncrementalBuildState> loadConfig(nz.org.riskscape.engine.pipeline.ExecutionContext context, Map<String,List<?>> configToLoad)

      Produces a IncrementalBuildState that's the same (roughly) as if the saved INI configToLoad had been entered as answers to the interactive wizard.

    • loadConfig2

      public nz.org.riskscape.problem.ResultOrProblems<IncrementalBuildState> loadConfig2(Survey survey, nz.org.riskscape.engine.pipeline.ExecutionContext context, Map<String,List<?>> configToLoad)

      Produces a IncrementalBuildState that's the same (roughly) as if the saved INI configToLoad had been entered as answers to the interactive wizard.

    • getConfigToWrite

      public Stream<nz.org.riskscape.engine.util.Pair<String,String>> getConfigToWrite(IncrementalBuildState buildState)
      Returns:
      A stream of unescaped key/value pairs, suitable for writing to a standard config file (like an ini file) which, when read back in to a sorted map, can be parsed by this config parser