Class Answer


public class Answer extends Object

Records an answer to a question that has been bound to a type according to Question.getParameterType()

Note that an Answer can simply indicate that a Question was presented to the user, even if the user choose to skip it and not give an actual response.

  • Constructor Details

  • Method Details

    • bind

      public static<Answer.Response> bind( context, Question chosen, Object input)

      Convenience method for binding a single input value for the given question in to a single Answer.Response

    • bindAll

      public static<Answer> bindAll( context, Question question, List<?> responses)

      Convenience method for binding a list of responses in to an answer, return a failed result if any of the responses failed to bind.

    • strings

      public static Answer strings(Question answered, String... valuesAndResponses)

      Useful testing constructor for creating answers for tests where the bound type is a string as well.

    • single

      public static Answer single(Question answered, Object boundValue, Object response)

      Useful testing constructor for assembling a single response answer

    • hidden

      public static Answer hidden(Question answered)
      an Answer that is suitable for the given hidden question
    • skip

      public static Answer skip(Question notAnswered)
      an Answer that represents the user skipping the given question
    • getValues

      public List<Object> getValues()
    • getValuesAs

      public <T> List<T> getValuesAs(Class<T> asClass)

      Returns the bound value(s) for this answer as the given class.

    • getValueAs

      public <T> T getValueAs(Class<T> asClass)
      the bound value for the answer as the given class
    • getResponse

      public Answer.Response getResponse()
      the Answer.Response object that stores both the user supplied value and the bound value for this answer, or null if no response was recorded.
      IllegalArgumentException - if the question answered doesn't expect a single response
    • getOriginalResponses

      public List<Object> getOriginalResponses()
    • isSameQuestion

      public boolean isSameQuestion(Question rhsQuestion)

      Returns true if this answer was given for the given question and question set

    • getId

      public String getId()
      the ID of the Question being answered
    • getQuestionSet

      public QuestionSet getQuestionSet()
    • toString

      public String toString()
      toString in class Object
    • toParameter

      public toParameter()
    • isEmpty

      public boolean isEmpty()
      true if this answer has no responses recorded, i.e. the Question was skipped.
    • equals

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

      protected boolean canEqual(Object other)
    • hashCode

      public int hashCode()
      hashCode in class Object
    • getQuestion

      public Question getQuestion()

      The question that was answered