我是新來的流口水。 我想檢查RHS,如果一個字段是否存在於POJO中。提供在RHS中檢查存在pojo內的字段在drools
{
"category": [
{
"nlp": [
{
"mainCategory": "Politics"
}
],
"crawler": [
{
"isNLP": true,
"mainCategory": "Politics"
}
]
}
]
}
這是產生
- EsRootDoc.java
- Crawler.java
- Nlp.java
EsRootDoc的POJO的列表具有主類方法和領域。「當
$RHSmap1:EsRootDoc()
and
$map1:EsRootDoc($categorylist1:category)
$category2:Category($nlplist2:nlp) from $categorylist1
$nlp2:Nlp(mainCategory=="politics") from $nlplist2
then
$RHSmap1.setEvent("fight");
end`
這是給我下面的錯誤
[Error: unable to resolve method using strict-mode: com.orkash.EnrichmentService.EnrichmentController.tempJsonToClass.EsRootDoc.setEvent(java.lang.String)] [Near : {... $RHSmap1.setEvent("fight"); ....}]
我需要提供在RHS檢查: - 如果EsRootDoc有一個字段事件或不
規則的RHS是強類型。你的'EsRootDoc'類是否有'setEvent(String)'方法? –
不,它沒有這種方法。我的用例是,我需要提供一個檢查之前調用setter方法,如果EsRootDoc有事件字段,那麼只有它應該調用** setEvent(String)**方法 – gaurav9620
你用普通的Java來做到這一點?你的'EsRootDocument'類是怎樣的?我假設它有某些子類具有這種方法,而另一些子類沒有。對? –