public static Rule getRule ( final Stack stack ) { if ( stack . size ( ) < 2 ) { throw new IllegalArgumentException ( "Invalid AND rule - expected two rules but received " + stack . size ( ) ) ; } Object o2 = stack . pop ( ) ; Object o1 = stack . pop ( ) ; if ( ( o2 instanceof Rule ) && ( o1 instanceof Rule ) ) { Rule p2 = ( Rule ) o2 ; Rule p1 = ( Rule ) o1 ; return new AndRule ( p1 , p2 ) ; } throw new IllegalArgumentException ( "Invalid AND rule: " + o2 + "..." + o1 ) ; }
Create rule from top two elements of stack .