2014-01-08 2 views
0

String 목록의 값이 다른 String 목록의 멤버 인 경우 drools을 확인하는 방법을 찾는 데 문제가 있습니다.Drools : String 목록의 모든 값이 다른 String 목록의 멤버입니다.

when 

//any value of stringList1 member of stringList2 

then 

// whatever... 

나는 forall 연산을 사용할 수 있지만 여전히 길을 찾을 수 없습니다. 어떤 도움이 ..?

public final class StringListValidationBean { 

    private List<String> stringList1; 
    private List<String> stringList2; 
    //... gets & sets 

} 

답변

1

이 시도 :

의 내 검증 콩 뭔가 같은 것은 가정 해 봅시다

ValidationBean를 사용하는 것이 필수적이다 경우 목록이 빈 내에서 참조 할 수
rule someString 
when 
    $l1: List() 
    $s: String() from $l1 
    List(hashCode > $l1.hashCode, this contains $s) 
then 
    System.out.println("both: " + $s); 
end 

:

$vb: ValidationBean($sl1: stringList1) 
$s: String() from $sl1 
ValidationBean(this == $vb, stringList2 contains $s) 

두 목록에 포함 된 각 문자열에 대해 실행됩니다.

또 다른 방법

은 List.retainAll를 (사용하는 DRL 기능),

function boolean (List l1, List l2){ 
    List is = new ArrayList(l1); 
    is.retainAll(l2); 
    return is.size() > 0; 
} 

같은 수 또는 기능은 일반 문자열 목록을 반환 할 것입니다.

관련 문제