drools 将添加switch支持

例子如下。
rule eatFoodOrPill when
    $s : Score()  
    $char : Character( name == "Pacman" )
    $l : Location( character == $char )
    $target : Cell( row == $l.row, col == $l.col)
    $contents : CellContents( cell == $target )
    switch( cellType ) {
        case CellType.FOOD : {  
            do[scorePlus1]      
            $update : ScheduledLocationUpdate( character == $char )
            do[slowWhenEating]
        }
        case CellType.POWER_PILL  : {
            do[scorePlus5]        
            $update : ScheduledLocationUpdate( character == $char )
            do[slowWhenEating]            
        }        
    }
then[slowWhenEating]  
    modify ( $update ) { tock += 2 };
then[scorePlus1]
    modify( $contents ) { cellType = CellType.EMPTY };
    modify( $s ) { score += 5 };    
then[scorePlus5]
    modify( $contents ) { cellType = CellType.EMPTY };
    modify( $s ) { score += 5 };     
end

你可能感兴趣的:(drools)