All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.drools.lang.api.impl.CEDescrBuilderImpl Maven / Gradle / Ivy

There is a newer version: 10.0.0
Show newest version
/*
 * Copyright 2011 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.
 */

package org.drools.lang.api.impl;

import org.drools.lang.api.AccumulateDescrBuilder;
import org.drools.lang.api.CEDescrBuilder;
import org.drools.lang.api.DescrBuilder;
import org.drools.lang.api.EvalDescrBuilder;
import org.drools.lang.api.ForallDescrBuilder;
import org.drools.lang.api.PatternDescrBuilder;
import org.drools.lang.descr.AndDescr;
import org.drools.lang.descr.BaseDescr;
import org.drools.lang.descr.ConditionalElementDescr;
import org.drools.lang.descr.ExistsDescr;
import org.drools.lang.descr.NotDescr;
import org.drools.lang.descr.OrDescr;

/**
 * An implementation for the CEDescrBuilder
 */
public class CEDescrBuilderImpl

, T extends BaseDescr> extends BaseDescrBuilderImpl implements CEDescrBuilder { public CEDescrBuilderImpl(P parent, T descr) { super( parent, descr ); } /** * {@inheritDoc} */ public CEDescrBuilder, AndDescr> and() { AndDescr andDescr = new AndDescr(); ((ConditionalElementDescr) descr).addDescr( andDescr ); CEDescrBuilder, AndDescr> and = new CEDescrBuilderImpl, AndDescr>( this, andDescr ); return and; } /** * {@inheritDoc} */ public CEDescrBuilder, OrDescr> or() { OrDescr orDescr = new OrDescr(); ((ConditionalElementDescr) descr).addDescr( orDescr ); CEDescrBuilder, OrDescr> or = new CEDescrBuilderImpl, OrDescr>( this, orDescr ); return or; } /** * {@inheritDoc} */ public CEDescrBuilder, NotDescr> not() { CEDescrBuilder, NotDescr> not = new CEDescrBuilderImpl, NotDescr>( this, new NotDescr() ); ((ConditionalElementDescr) descr).addDescr( not.getDescr() ); return not; } /** * {@inheritDoc} */ public CEDescrBuilder, ExistsDescr> exists() { CEDescrBuilder, ExistsDescr> exists = new CEDescrBuilderImpl, ExistsDescr>( this, new ExistsDescr() ); ((ConditionalElementDescr) descr).addDescr( exists.getDescr() ); return exists; } /** * {@inheritDoc} */ public ForallDescrBuilder> forall() { ForallDescrBuilder> forall = new ForallDescrBuilderImpl>( this ); ((ConditionalElementDescr) descr).addDescr( forall.getDescr() ); return forall; } /** * {@inheritDoc} */ public AccumulateDescrBuilder> accumulate() { // here we have to do a trick as a top level accumulate is just an accumulate // whose result pattern is Object[] // create a linked Object[] pattern and set it to query false PatternDescrBuilder> pdb = pattern("Object[]").isQuery( false ); // create the accumulate builder with this CE as its parent AccumulateDescrBuilder> accumulate = new AccumulateDescrBuilderImpl>(this) .multiFunction( true ); // set the accumulate descriptor as the source of that pattern descr pdb.getDescr().setSource( accumulate.getDescr() ); // return the accumulate builder, that has the properly set parent return accumulate; } /** * {@inheritDoc} */ public EvalDescrBuilder> eval() { EvalDescrBuilder> eval = new EvalDescrBuilderImpl>( this ); ((ConditionalElementDescr) descr).addDescr( eval.getDescr() ); return eval; } /** * {@inheritDoc} */ public PatternDescrBuilder> pattern( String type ) { PatternDescrBuilder> pattern = new PatternDescrBuilderImpl>( this, type ); ((ConditionalElementDescr) descr).addDescr( pattern.getDescr() ); return pattern; } /** * {@inheritDoc} */ public PatternDescrBuilder> pattern() { PatternDescrBuilder> pattern = new PatternDescrBuilderImpl>( this ); ((ConditionalElementDescr) descr).addDescr( pattern.getDescr() ); return pattern; } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy