Class PredefinedAnswers
java.lang.Object
ch.tocco.nice2.web.core.api.clientquestion.PredefinedAnswers
Defines predefined answers for client questions.
The answers are mapped to a predicate which is applied to the questions.
Call
getForQuestion(ClientQuestion)
to get the answer for a certain question.-
Nested Class Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescription<T extends ClientAnswer>
PredefinedAnswersadd
(PredefinedAnswers.Answer<T> predefinedAnswer) <T extends ClientAnswer>
PredefinedAnswersadd
(Predicate<ClientQuestion<T>> questionFilter, T answer) <T extends ClientAnswer>
PredefinedAnswersaddAll
(Collection<PredefinedAnswers.Answer<T>> predefinedAnswers) static <T extends ClientAnswer>
Predicate<ClientQuestion<T>> answerClass
(Class<T> answerClass) static <T extends ClientAnswer>
Predicate<ClientQuestion<T>> clientHandlerName
(String clientHandlerName) getAll()
<T extends ClientAnswer>
Optional<T> getForQuestion
(ClientQuestion<T> question) Get the predefined answer for a certain question.static <T extends ClientAnswer>
Predicate<ClientQuestion<T>> questionId
(String questionId) static <T extends ClientAnswer>
Predicate<ClientQuestion<T>>
-
Constructor Details
-
PredefinedAnswers
public PredefinedAnswers()
-
-
Method Details
-
add
public <T extends ClientAnswer> PredefinedAnswers add(Predicate<ClientQuestion<T>> questionFilter, T answer) -
add
-
addAll
public <T extends ClientAnswer> PredefinedAnswers addAll(Collection<PredefinedAnswers.Answer<T>> predefinedAnswers) -
getForQuestion
Get the predefined answer for a certain question. The question is applied to the predicates of the available answers. The answer for the first matching predicate is returned.- Parameters:
question
- The question to get the answer for.- Returns:
- the predefined answer or
Optional.empty()
, if not available.
-
getAll
-
questionId
-
type
-
clientHandlerName
public static <T extends ClientAnswer> Predicate<ClientQuestion<T>> clientHandlerName(String clientHandlerName) -
answerClass
public static <T extends ClientAnswer> Predicate<ClientQuestion<T>> answerClass(Class<T> answerClass)
-