Class AskAs<T>

java.lang.Object
nz.org.riskscape.wizard.AskAs<T>

public class AskAs<T> extends Object

An AskAs is a way for a Question to signal to the UI that it can ask the question in a customized way, but ultimately the survey wants the answer to be recorded in a way that can be bound to the Question's parameter type. This allows a user-friendly experience for certain options while being able to still allow a more complex, custom value to be edited in "expert mode" scenarios (such as editing an ini file, or switching a GUI in to expert mode)

NB at the moment, ask as questions are assumed to always be composite, as they are the only examples we've seen so far. There's no reason for it to need to be this way, but it was simpler at the time.

  • Constructor Details

  • Method Details

    • toAnswer

      public String toAnswer(T delegatedAskerBoundValue)
    • convert

      public nz.org.riskscape.problem.ResultOrProblems<Answer.Response> convert(nz.org.riskscape.engine.bind.BindingContext context, Question question, Answer.Response response)

      Convert the result of asking the question (getType()) to the type the survey wants to have stored (Question#getType()

    • asType

      public Question asType(Question parent)
      Returns:
      a modified copy of parent with the parametertype set to the ask as type and with the ask as information removed
    • getCompositeSubparts

      public List<Question> getCompositeSubparts(Question parent)
      Returns:
      a list of questions that can be used to build a response to this question when 'asked as'
    • getType

      public Class<T> getType()
    • getToAnswer

      public Function<T,String> getToAnswer()
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • canEqual

      protected boolean canEqual(Object other)
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object