2014-04-17 1 views
0

.drl 규칙 파일에서 arrayList를 사용하고 있습니다. 하나의 규칙에서 나는 목록이 null인지 아닌지 확인하고 setFocus (2 번째 규칙)를 설정합니다. 2 규칙에서 나는 목록에서 요소를 얻고 있습니다.이 규칙에서 bt는 목록을 얻는 중 Null 오류입니다.DRools 규칙에서 Null 배열을 탐색하는 중 오류가 발생했습니다.

목록이 비어 있는지 확인하고 싶습니다. 하나의 규칙에서 그 arraylist의 특정 요소를 가져오고 싶습니다.

rule "Rule chesks client had already received Notifications or Not" 
salience 10 
no-loop true 
when 
    event : Event($listOfClientNotifications : clientNotifications) 
    eval($listOfClientNotifications < 1) 
then 
    event.setMessage("list is null"); 
end 

2 규칙 : 널 오류가 발생하는 위치

rule "Rule chesks " 
salience 05 
no-loop true 
when 
    event : Event($listOfClientNotifications : clientNotifications) 
    value : ClientNotifications() from $listOfClientNotifications; // <<< !!! 
then 
    event.setMessage("Value "+**value.getMessage()**); 
end 

<<< !!!입니다.

답변

0

한 규칙에서 Null에 대해 목록을 테스트하면 다른 규칙의 NPE로 실행되는 것을 피할 수 없습니다. 규칙 평가는 이 아니며이 아니며 반복은 규칙 실행, 중요도 및 활성화 그룹과 동기화되어 이 아니며이 아닙니다.

이 정확한 검사입니다 : NPE로 실행에 대한

rule "check list is null" 
when 
    event : Event(clientNotifications == null) 
then 
    event.setMessage("list is null"); 
end 

가드

rule "use notifications from list" 
when 
    event : Event($listOfClientNotifications : clientNotifications != null) 
    value : ClientNotifications() from $listOfClientNotifications; 
then 
    event.setMessage("Value "+ value.getMessage()); // strange, but maybe? 
end 
관련 문제