public RuleConditionElement build(final RuleBuildContext context,
final BaseDescr descr,
final Pattern prefixPattern) {
final ConditionalElementDescr cedescr = (ConditionalElementDescr) descr;
final GroupElement ge = this.newGroupElementFor( descr );
context.getBuildStack().push( ge );
if ( prefixPattern != null ) {
ge.addChild( prefixPattern );
}
// iterate over child descriptors
for ( final Iterator it = cedescr.getDescrs().iterator(); it.hasNext(); ) {
// gets child to build
final BaseDescr child = (BaseDescr) it.next();
child.setResource(context.getRuleDescr().getResource());
child.setNamespace(context.getRuleDescr().getNamespace());
// gets corresponding builder
final RuleConditionBuilder builder = (RuleConditionBuilder) context.getDialect().getBuilder( child.getClass() );
if ( builder != null ) {
final RuleConditionElement element = builder.build( context,
child );
// in case there is a problem with the building,
// builder will return null. Ex: ClassNotFound for the pattern type
if ( element != null ) {
ge.addChild( element );
}
} else {
throw new RuntimeDroolsException( "BUG: no builder found for descriptor class " + child.getClass() );
}