public class QuestionnaireReq {
private String questionId;
private List<String> answerText;
public String getQuestionId() {
return questionId;
}
public void setQuestionId(String questionId) {
this.questionId = questionId;
}
public List<String> getAnswerText() {
return answerText;
}
public void setAnswerText(List<String> answerText) {
this.answerText = answerText;
}
}
and drools file
rule "qustionRule_3"
when
questionnaireReq : QuestionnaireReq(questionId=="q2" && $answerText=="Web UI front-end");
questionnaireRes : QuestionnaireRes();
then
questionnaireRes.setNextQuestionId("q3");
end
and postman request here
{
"questionId":"q3",
"answerText":["Web UI front-end","Web Back-end"]
}
I think what you're trying to ask is how to update your rule to check that a value is in a list, since your original rule is trying to do an ==
which will never match since you're comparing a list to a string.
In this case you'll want to use the Drools contains
operator, which verifies that a list contains a given element.
rule "qustionRule_3"
when
questionnaireReq : QuestionnaireReq( questionId=="q2",
answerText contains "Web UI front-end")
questionnaireRes : QuestionnaireRes()
then
questionnaireRes.setNextQuestionId("q3");
end
You can read more about the contains
operator in the official Drools documentation, in the section called "Supported operators in DRL pattern constraints" .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.