From: <jbo...@li...> - 2006-04-20 02:24:18
|
Author: mar...@jb... Date: 2006-04-19 22:24:13 -0400 (Wed, 19 Apr 2006) New Revision: 3819 Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/GroupElement.java Log: -Fix broken test with GroupElement Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/GroupElement.java =================================================================== --- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/GroupElement.java 2006-04-20 01:26:35 UTC (rev 3818) +++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/GroupElement.java 2006-04-20 02:24:13 UTC (rev 3819) @@ -53,41 +53,40 @@ // } // } -// if ( child instanceof GroupElement && ( child instanceof And || child instanceof Or ) ) { -// GroupElement group = ( GroupElement ) child; -// -// // Removal single branch group elements -// // If the child is a GroupElement iterate down until we either -// // find a GroupElement that has more than one children, or its not a GroupElement -// if ( group.getChildren().size() == 1 ) { -// child = group.getChildren().get( 0 ); -// } -// } -// -// if ( child instanceof GroupElement && ( child instanceof And || child instanceof Or ) ) { -// GroupElement group = ( GroupElement ) child; -// -// // Remove nested Ands/Ors -// if ( group.getClass() == this.getClass() ) { -// -// GroupElement newGroup = null; -// if ( group instanceof And) { -// newGroup = new And(); -// } else { -// newGroup = new Or(); -// } -// -// for ( Iterator it = group.getChildren().iterator(); it.hasNext(); ) { -// this.children.add( it.next() ); -// } -// } else { -// this.children.add( child ); -// } -// } else { -// this.children.add( child ); -// } + if ( child instanceof GroupElement && ( child instanceof And || child instanceof Or ) ) { + GroupElement group = ( GroupElement ) child; + + // Removal single branch group elements + // If the child is a GroupElement iterate down until we either + // find a GroupElement that has more than one children, or its not a GroupElement + if ( group.getChildren().size() == 1 ) { + child = group.getChildren().get( 0 ); + } + } - this.children.add( child ); + if ( child instanceof GroupElement && ( child instanceof And || child instanceof Or ) ) { + GroupElement group = ( GroupElement ) child; + + // Remove nested Ands/Ors + if ( group.getClass() == this.getClass() ) { + + GroupElement newGroup = null; + if ( group instanceof And) { + newGroup = new And(); + } else { + newGroup = new Or(); + } + + for ( Iterator it = group.getChildren().iterator(); it.hasNext(); ) { + this.children.add( it.next() ); + } + } else { + this.children.add( child ); + } + } else { + this.children.add( child ); + } + } public List getChildren() { |