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

org.drools.compiler.lang.api.impl.FieldDescrBuilderImpl Maven / Gradle / Ivy

There is a newer version: 10.0.0
Show newest version
package org.drools.compiler.lang.api.impl;

import org.drools.compiler.lang.api.DescrBuilder;
import org.drools.compiler.lang.api.FieldDescrBuilder;
import org.drools.compiler.lang.descr.PatternDescr;
import org.drools.compiler.lang.descr.TypeFieldDescr;
import org.drools.compiler.lang.api.AnnotationDescrBuilder;
import org.drools.core.rule.TypeDeclaration;

public class FieldDescrBuilderImpl> extends BaseDescrBuilderImpl
    implements
        FieldDescrBuilder {

    protected FieldDescrBuilderImpl( T parent, String name ) {
        super( parent, new TypeFieldDescr( name ) );
    }

    public AnnotationDescrBuilder> newAnnotation( String name ) {
        AnnotationDescrBuilder> annotation = new AnnotationDescrBuilderImpl>( this, name );
        descr.addAnnotation( annotation.getDescr() );
        return annotation;
    }

    public FieldDescrBuilder index( int index ) {
        descr.setIndex( index );
        return this;
    }

    public FieldDescrBuilder name( String name ) {
        descr.setFieldName( name );
        return this;
    }

    public FieldDescrBuilder type( String type ) {
        descr.setPattern( new PatternDescr( type ) );
        return this;
    }

    public FieldDescrBuilder initialValue( String value ) {
        descr.setInitExpr( value );
        return this;
    }


    public FieldDescrBuilder processAnnotations() {
        if ( descr.getAnnotations().containsKey( TypeDeclaration.ATTR_FIELD_POSITION ) ) {
             int pos = Integer.valueOf(descr.getAnnotation( TypeDeclaration.ATTR_FIELD_POSITION ).getSingleValue());
             descr.setIndex(pos);
        }
        return this;
    }


}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy