So as not to confuse everybody - it seems that the 5.1 textual version of a dsl now looks like this:
[condition][]There is an element {eVar}={eVar} : Element()
[condition][]- called {nVar}={nVar} : name
[condition][]- other than {oVar}=this != {oVar}
[condition][]- where {eVar} is disjoint from {oVar}=eval( {eVar}.disjointWith( {oVar} ) )
[condition][]- where {eVar} intersects with {oVar}=eval( ! {eVar}.disjointWith( {oVar} ) )
[consequence][]show disjoint {n1Var} and {n2Var}=System.out.println( {n1Var} + " and " + {n2Var} + " are disjoint.");
[consequence][]show intersecting {n1Var} and {n2Var}=System.out.println( {n1Var} + " and " + {n2Var} + " intersect.");
(The documentation is not up-to-date, is it?)
-W
On 26 August 2010 16:15, Wolfgang Laun <wolfgang.laun@gmail.com> wrote:
It is possible to hide the eval for computing the intersection in a DSL.
Given
public class Element {
private String name;
private Set<Integer> numbers;
public Element( String name, Integer... numbers ){ ... }
// getters...
public boolean disjointWith( Element other ){
Set<Integer> ownNumbers = new HashSet<Integer>( this.numbers );
ownNumbers.retainAll( other.getNumbers() );
return ownNumbers.isEmpty();
}
}
and the dsl
[when]There is an element {eVar}={eVar} : Element()
[when]- called {nVar}={nVar} : name
[when]- other than {oVar}=this != {oVar}
[when]- where {eVar} is disjoint from {oVar}=eval(
{eVar}.disjointWith( {oVar} ) )
[when]- where {eVar} intersects with {oVar}=eval( !
{eVar}.disjointWith( {oVar} ) )
[then]show disjoint {n1Var} and {n2Var}=System.out.println( {n1Var} +
" and " + {n2Var} + " are disjoint.");
[then]show intersecting {n1Var} and {n2Var}=System.out.println(
{n1Var} + " and " + {n2Var} + " intersect.");
you can write the drsl
package appl.domain
expander elements.dsl
rule "find disjoint pairs"
when
There is an element e1
- called n1
There is an element e2
- called n2
- other than e1
- where e1 is disjoint from e2
then
show disjoint n1 and n2
end
> Thanks for your response.
>
> I need to use it like 1-4 times depending on what the legacy rules are setup
> on one rule but i do have thousands of rules.
> Also, a future state might be to get these imported into a tool for business
> users to start writing these and would definitely be more pleasing if they
> had an operator that they could use.
> Would you be able to point me to some resources on how to do the custom
> operator
> if the need arise.
>
> thanks again for your time.
> --
> View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/comparing-an-intersection-of-sets-tp1313555p1332184.html
> Sent from the Drools - User mailing list archive at Nabble.com.
> _______________________________________________
> rules-users mailing list
> rules-users@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>