Package org.drools.factmodel

Examples of org.drools.factmodel.FieldDefinition


        // Fields are SORTED in the process
        if (!typeDescr.getFields().isEmpty()) {
            PriorityQueue<FieldDefinition> fieldDefs = sortFields( typeDescr.getFields(),
                                                                   pkgRegistry );
            while (fieldDefs.size() > 0) {
                FieldDefinition fld = fieldDefs.poll();
                def.addField( fld );
            }
        }

        // check whether it is necessary to build the class or not
View Full Code Here


            try {
                String typeName = field.getPattern().getObjectType();
                String fullFieldType = generatedTypes.contains(typeName) ? typeName : pkgRegistry.getTypeResolver().resolveType(typeName).getName();

                FieldDefinition fieldDef = new FieldDefinition( field.getFieldName(),
                                                                fullFieldType );
                // field is marked as PK
                boolean isKey = field.getAnnotation( TypeDeclaration.ATTR_KEY ) != null;
                fieldDef.setKey( isKey );

                fieldDef.setIndex( field.getIndex() );
                fieldDef.setInherited( field.isInherited() );
                fieldDef.setInitExpr( field.getInitExpr() );

                for (String annotationName : field.getAnnotationNames()) {
                    Class annotation = resolveAnnotation( annotationName,
                                                          pkgRegistry.getTypeResolver() );
                    if (annotation != null) {
                        try {
                            AnnotationDefinition annotationDefinition = AnnotationDefinition.build( annotation,
                                                                                                    field.getAnnotations().get( annotationName ).getValueMap(),
                                                                                                    pkgRegistry.getTypeResolver() );
                            fieldDef.addAnnotation( annotationDefinition );
                        } catch (NoSuchMethodException nsme) {
                            this.results.add( new TypeDeclarationError( field,
                                                                        "Annotated field " + field.getFieldName() +
                                                                        "  - undefined property in @annotation " +
                                                                        annotationName + ": " + nsme.getMessage() + ";" ) );
View Full Code Here

            return;
        }

        //add the missing fields (if any) to newDeclaration
        for ( FieldDefinition oldFactField : oldDeclaration.getTypeClassDef().getFieldsDefinitions() ) {
            FieldDefinition newFactField = newDeclaration.getTypeClassDef().getField( oldFactField.getName() );
            if ( newFactField == null){
                newDeclaration.getTypeClassDef().addField( oldFactField );
            }
        }
View Full Code Here

        }

        for ( Field fld : fields ) {
            Position pos = fld.getAnnotation( Position.class );
            if ( pos != null ) {
                FieldDefinition fldDef = new FieldDefinition( fld.getName(),
                                                              fld.getType().getName() );
                fldDef.setIndex( pos.value() );
                orderedFields.set( pos.value(),
                                   fldDef );
            }
        }
        for ( FieldDefinition fld : orderedFields ) {
View Full Code Here

                    continue;
                }
                if (!inspector.isNonGetter( fieldName ) && setters.keySet().contains( fieldName )) {

                    Class ret = methods.get( fieldName ).getReturnType();
                    FieldDefinition field = new FieldDefinition();
                    field.setName( fieldName );
                    field.setTypeName( ret.getName() );
                    field.setIndex( j++ );
                    type.getTypeClassDef().addField( field );
                }
            }

            Set<String> interfaces = new HashSet<String>();
View Full Code Here

        // Fields are SORTED in the process
        if (typeDescr.getFields().size() > 0) {
            PriorityQueue<FieldDefinition> fieldDefs = sortFields( typeDescr.getFields(),
                                                                   pkgRegistry );
            while (fieldDefs.size() > 0) {
                FieldDefinition fld = fieldDefs.poll();
                def.addField( fld );
            }
        }

        // check whether it is necessary to build the class or not
View Full Code Here

            String fullFieldType;
            try {
                fullFieldType = pkgRegistry.getTypeResolver().resolveType( field.getPattern().getObjectType() ).getName();

                FieldDefinition fieldDef = new FieldDefinition( field.getFieldName(),
                                                                fullFieldType );
                // field is marked as PK
                boolean isKey = field.getAnnotation( TypeDeclaration.ATTR_KEY ) != null;
                fieldDef.setKey( isKey );

                fieldDef.setIndex( field.getIndex() );
                fieldDef.setInherited( field.isInherited() );
                fieldDef.setInitExpr( field.getInitExpr() );

                for (String annotationName : field.getAnnotationNames()) {
                    Class annotation = resolveAnnotation( annotationName,
                                                          pkgRegistry.getTypeResolver() );
                    if (annotation != null) {
                        try {
                            AnnotationDefinition annotationDefinition = AnnotationDefinition.build( annotation,
                                                                                                    field.getAnnotations().get( annotationName ).getValueMap(),
                                                                                                    pkgRegistry.getTypeResolver() );
                            fieldDef.addAnnotation( annotationDefinition );
                        } catch (NoSuchMethodException nsme) {
                            this.results.add( new TypeDeclarationError( "Annotated field " + field.getFieldName() +
                                                                        "  - undefined property in @annotation " +
                                                                        annotationName +
                                                                        ": " +
View Full Code Here

        }

        for (Field fld : fields) {
            Position pos = fld.getAnnotation( Position.class );
            if (pos != null) {
                FieldDefinition fldDef = new FieldDefinition( fld.getName(),
                                                              fld.getType().getName() );
                fldDef.setIndex( pos.value() );
                orderedFields.set( pos.value(),
                                   fldDef );
            }
        }
        for (FieldDefinition fld : orderedFields) {
View Full Code Here

                    continue;
                }
                if (!inspector.isNonGetter( fieldName ) && setters.keySet().contains( fieldName )) {

                    Class ret = methods.get( fieldName ).getReturnType();
                    FieldDefinition field = new FieldDefinition();
                    field.setName( fieldName );
                    field.setTypeName( ret.getName() );
                    field.setIndex( j++ );
                    type.getTypeClassDef().addField( field );
                }
            }

            Set<String> interfaces = new HashSet<String>();
View Full Code Here

        // Fields are SORTED in the process
        if (typeDescr.getFields().size() > 0) {
            PriorityQueue<FieldDefinition> fieldDefs = sortFields( typeDescr.getFields(),
                                                                   pkgRegistry );
            while (fieldDefs.size() > 0) {
                FieldDefinition fld = fieldDefs.poll();
                def.addField( fld );
            }
        }

        // check whether it is necessary to build the class or not
View Full Code Here

TOP

Related Classes of org.drools.factmodel.FieldDefinition

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.