corrade-nucleus-nucleons

Subversion Repositories:
Compare Path: Rev
With Path: Rev
?path1? @ 19  →  ?path2? @ 20
/script-kiddie/002_script_kiddie/script-kiddie/node_modules/ace-builds/demo/kitchen-sink/docs/drools.drl
@@ -0,0 +1,127 @@
/*
* Copyright 2010 JBoss Inc
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
 
/*
Original source
https://github.com/droolsjbpm/drools/blob/master/drools-examples/
http://docs.jboss.org/drools/
*/
package com.example.ace
 
import java.math.BigDecimal
import function my.package.Foo.hello
 
declare FactType
@author( Bob )
id : String
name : String @maxLength(100) @notnull
 
value : BigDecimal
end
 
declare FactType2 extends AnotherType
end
 
declare trait TraitType extends com.package.AnotherType
end
 
 
declare trait GoldenCustomer
balance : long @Alias( "org.acme.foo.accountBalance" )
end
 
global org.slf4j.Logger logger
 
/**
* @param name who we'll salute?
*/
function String hello(String name) {
return "Hello "+name+"!";
}
 
rule "Trim all strings"
dialect "java"
no-loop
when // fdsfds
$s : String(a == null || == "empty", $g : size)
Cheese( name matches "(Buffalo)?\\S*Mozarella" )
CheeseCounter( cheeses contains $var ) // contains with a variable
CheeseCounter( cheese memberof $matureCheeses )
Cheese( name soundslike 'foobar' )
Message( routingValue str[startsWith] "R1" )
Cheese( name in ( "stilton", "cheddar", $cheese ) )
Person( eval( age == girlAge + 2 ), sex = 'M' )
then
/**
* TODO There mus be better way
*/
retract($s);
String a = "fd";
a.toString();
 
insert($s.trim());
end
 
query isContainedIn( String x, String y )
Location( x, y; )
or
( Location( z, y; ) and isContainedIn( x, z; ) )
end
 
rule "go" salience 10
when
$s : String( )
then
System.out.println( $s );
end
 
rule "When all English buses are not red"
when
not(forall( $bus : Bus( nationality == 'english')
Bus( this == $bus, color = 'red' ) ))
then
// What if all english buses are not red?
end
 
rule "go1"
when
String( this == "go1" )
isContainedIn("Office", "House"; )
then
System.out.println( "office is in the house" );
end
 
rule "go2"
when
String( this == "go2" )
isContainedIn("Draw", "House"; )
then
System.out.println( "Draw in the House" );
end
 
/**
* Go Right
*/
rule GoRight dialect "mvel" salience (Math.abs( $df.colDiff )) when
$df : DirectionDiff(colDiff > 0 )
$target : Cell( row == $df.row, col == ($df.col + 1) )
CellContents( cell == $target, cellType != CellType.WALL )
not Direction(character == $df.fromChar, horizontal == Direction.RIGHT )
then
System.out.println( "monster right" );
retract( $df );
insert( new Direction($df.fromChar, Direction.RIGHT, Direction.NONE ) );
end