Examples of TypeDeclarationDescr


Examples of org.drools.lang.descr.TypeDeclarationDescr

                if ( mergeInheritedFields( typeDescr ) ) {
                    //descriptor also needs metadata from superclass
                    Iterator<TypeDeclarationDescr> iter = sortedTypeDescriptors.iterator();
                    while ( iter.hasNext() ) {
                        // sortedTypeDescriptors are sorted by inheritance order, so we'll always find the superClass (if any) before the subclass
                        TypeDeclarationDescr descr = iter.next();
                        if ( qname.equals( descr.getType() ) ) {
                            typeDescr.getAnnotations().putAll( descr.getAnnotations() );
                            break;
                        } else if ( typeDescr.getType().equals( descr.getType() ) ) {
                            break;
                        }
                    }
                }
            }
View Full Code Here

Examples of org.drools.lang.descr.TypeDeclarationDescr

                    if ( !Thing.class.isAssignableFrom( resolvedType ) ) {
                        updateTraitDefinition( type,
                                               resolvedType );

                        String target = typeDescr.getTypeName() + TraitFactory.SUFFIX;
                        TypeDeclarationDescr tempDescr = new TypeDeclarationDescr();
                        tempDescr.setNamespace( typeDescr.getNamespace() );
                        tempDescr.setFields( typeDescr.getFields() );
                        tempDescr.setType( target,
                                           typeDescr.getNamespace() );
                        tempDescr.addSuperType( typeDescr.getType() );
                        TypeDeclaration tempDeclr = new TypeDeclaration( target );
                        tempDeclr.setFormat( TypeDeclaration.Format.TRAIT );
                        tempDeclr.setTypesafe( type.isTypesafe() );
                        tempDeclr.setNovel( true );
                        tempDeclr.setTypeClassName( tempDescr.getType().getFullName() );
                        tempDeclr.setResource( type.getResource() );

                        ClassDefinition tempDef = new ClassDefinition( target );
                        tempDef.setClassName( tempDescr.getType().getFullName() );
                        tempDef.setTraitable( false );
                        for ( FieldDefinition fld : def.getFieldsDefinitions() ) {
                            tempDef.addField( fld );
                        }
                        tempDef.setInterfaces( def.getInterfaces() );
View Full Code Here

Examples of org.drools.lang.descr.TypeDeclarationDescr

    private List<TypeDeclarationDescr> getDeclaredTypeHierachy(TypeDeclarationDescr td,
                                                               List< ? > jars) {
        List<TypeDeclarationDescr> th = new ArrayList<TypeDeclarationDescr>();
        th.add( td );
        TypeDeclarationDescr std;
        while ( (std = getDeclaredSuperType( td )) != null ) {
            th.add( std );
            td = std;
        }

        //If the super-most class has been imported attempt to make a pseudo TypeDeclaration for the imported class
        if ( this.pkgDescr.getImports().size() > 0 ) {
            for ( ImportDescr imp : this.pkgDescr.getImports() ) {
                if ( imp.getTarget().endsWith( "." + td.getTypeName() ) ) {
                    TypeDeclarationDescr pseudoTypeDeclr = makePseudoTypeDeclarationDescrFromSuperClassType( imp.getTarget(),
                                                                                                             jars );
                    if ( pseudoTypeDeclr != null ) {
                        th.add( pseudoTypeDeclr );
                    }
                }
View Full Code Here

Examples of org.drools.lang.descr.TypeDeclarationDescr

            Method[] methods = clazz.getMethods();
            Map<String, MethodSignature> methodSignatures = getMethodSignatures( className,
                                                                                 methods );

            TypeDeclarationDescr td = new TypeDeclarationDescr();
            td.setTypeName( className );

            for ( Map.Entry<String, MethodSignature> e : methodSignatures.entrySet() ) {
                if ( e.getValue().accessorAndMutator == FieldAccessorsAndMutators.BOTH ) {
                    String fieldShortName = getShortNameOfClass( e.getKey() );
                    TypeFieldDescr fieldDescr = new TypeFieldDescr( fieldShortName );
                    PatternDescr patternDescr = new PatternDescr( e.getValue().returnType.getName() );
                    fieldDescr.setPattern( patternDescr );
                    td.addField( fieldDescr );
                }
            }
            return td;

        }
View Full Code Here

Examples of org.drools.lang.descr.TypeDeclarationDescr

                if ( mergeInheritedFields( typeDescr ) ) {
                    //descriptor also needs metadata from superclass
                    Iterator<TypeDeclarationDescr> iter = sortedTypeDescriptors.iterator();
                    while ( iter.hasNext() ) {
                        // sortedTypeDescriptors are sorted by inheritance order, so we'll always find the superClass (if any) before the subclass
                        TypeDeclarationDescr descr = iter.next();
                        if ( qname.equals( descr.getType() ) ) {
                            typeDescr.getAnnotations().putAll( descr.getAnnotations() );
                            break;
                        } else if ( typeDescr.getType().equals( descr.getType() ) ) {
                            break;
                        }
                    }
                }
            }
View Full Code Here

Examples of org.drools.lang.descr.TypeDeclarationDescr

                    Class< ? > resolvedType = reg.getTypeResolver().resolveType( availableName );
                    if ( ! Thing.class.isAssignableFrom( resolvedType) ) {
                        updateTraitDefinition( type, resolvedType );

                            String target = typeDescr.getTypeName() + TraitFactory.SUFFIX;
                            TypeDeclarationDescr tempDescr = new TypeDeclarationDescr();
                                tempDescr.setNamespace( typeDescr.getNamespace() );
                                tempDescr.setFields( typeDescr.getFields() );
                                tempDescr.setType( target, typeDescr.getNamespace() );
                                tempDescr.addSuperType( typeDescr.getType() );
                            TypeDeclaration tempDeclr = new TypeDeclaration( target );
                                tempDeclr.setFormat( TypeDeclaration.Format.TRAIT );
                                tempDeclr.setTypesafe( type.isTypesafe() );
                                tempDeclr.setNovel( true );
                                tempDeclr.setTypeClassName( tempDescr.getType().getFullName() );
                                tempDeclr.setResource( type.getResource() );

                            ClassDefinition tempDef = new ClassDefinition( target );
                                tempDef.setClassName( tempDescr.getType().getFullName() );
                                tempDef.setTraitable( false );
                                for ( FieldDefinition fld : def.getFieldsDefinitions() ) {
                                    tempDef.addField( fld );
                                }
                                tempDef.setInterfaces( def.getInterfaces() );
View Full Code Here

Examples of org.drools.lang.descr.TypeDeclarationDescr

        rule_return rl = null;

        query_return qr = null;

        TypeDeclarationDescr td = null;


        try {
            // src/main/resources/org/drools/lang/DescrBuilderTree.g:67:2: (a= rule_attribute | fi= function_import_statement | is= import_statement | gl= global | fn= function | tp= template | rl= rule | qr= query | td= type_declaration )
            int alt4=9;
View Full Code Here

Examples of org.drools.lang.descr.TypeDeclarationDescr


    // $ANTLR start type_declaration
    // src/main/resources/org/drools/lang/DescrBuilderTree.g:168:1: type_declaration returns [TypeDeclarationDescr declaration] : ^( VK_DECLARE id= VT_TYPE_DECLARE_ID (dm= decl_metadata )* (df= decl_field )* END ) ;
    public final TypeDeclarationDescr type_declaration() throws RecognitionException {
        TypeDeclarationDescr declaration = null;

        DroolsTree id=null;
        Map dm = null;

        TypeFieldDescr df = null;
View Full Code Here

Examples of org.drools.lang.descr.TypeDeclarationDescr

        final List<TypeDeclarationDescr> declarations = pkg.getTypeDeclarations();

        assertEquals( 2,
                      declarations.size() );

        TypeDeclarationDescr descr = declarations.get( 0 );
        assertEquals( "CallEvent",
                      descr.getTypeName() );
        assertEquals( 4,
                      descr.getAnnotationNames().size() );
        assertEquals( "event",
                          descr.getAnnotation( "role" ).getValue() );
        assertEquals( "org.drools.events.Call",
                          descr.getAnnotation( "class" ).getValue() );
        assertEquals( "duration",
                          descr.getAnnotation( "duration" ).getValue() );
        assertEquals( "timestamp",
                          descr.getAnnotation( "timestamp" ).getValue() );
        assertNull( descr.getAnnotation( "FOO" ) );

        descr = declarations.get( 1 );
        assertEquals( "some.pkg.Type",
                      descr.getTypeName() );
        assertEquals( 5,
                      descr.getAnnotationNames().size() );
        assertNotNull( descr.getAnnotation( "name1" ) );
        assertEquals( "\"value\"",
                          descr.getAnnotation( "name2" ).getValue() );
        assertEquals( "10",
                          descr.getAnnotation( "name3" ).getValue( "k1" ) );
        assertEquals( "\"a\"",
                      descr.getAnnotation( "name4" ).getValue( "k1" ) );
        assertEquals( "Math.max( 10 + 25, 22 ) % 2 + someVariable",
                      descr.getAnnotation( "name4" ).getValue( "formula" ) );
        assertEquals( "{ a, b, c }",
                      descr.getAnnotation( "name4" ).getValue( "array" ) );
        assertEquals( "backward compatible value",
                      descr.getAnnotation( "name5" ).getValue() );
    }
View Full Code Here

Examples of org.drools.lang.descr.TypeDeclarationDescr

        List<TypeDeclarationDescr> td = pkg.getTypeDeclarations();
        assertEquals( 3,
                      td.size() );

        TypeDeclarationDescr d = td.get( 0 );
        assertEquals( "SomeFact",
                          d.getTypeName() );
        assertEquals( 2,
                          d.getFields().size() );
        assertTrue( d.getFields().containsKey( "name" ) );
        assertTrue( d.getFields().containsKey( "age" ) );

        TypeFieldDescr f = d.getFields().get( "name" );
        assertEquals( "String",
                          f.getPattern().getObjectType() );

        f = d.getFields().get( "age" );
        assertEquals( "Integer",
                          f.getPattern().getObjectType() );

        d = td.get( 1 );
        assertEquals( "AnotherFact",
                          d.getTypeName() );

        TypeDeclarationDescr type = td.get( 2 );
        assertEquals( "Person",
                       type.getTypeName() );

        assertEquals( "fact",
                      type.getAnnotation( "role" ).getValue() );
        assertEquals( "\"Models a person\"",
                      type.getAnnotation( "doc" ).getValue( "descr" ) );
        assertEquals( "\"Bob\"",
                      type.getAnnotation( "doc" ).getValue( "author" ) );
        assertEquals( "Calendar.getInstance().getDate()",
                      type.getAnnotation( "doc" ).getValue( "date" ) );

        assertEquals( 2,
                      type.getFields().size() );
        TypeFieldDescr field = type.getFields().get( "name" );
        assertEquals( "name",
                      field.getFieldName() );
        assertEquals( "String",
                      field.getPattern().getObjectType() );
        assertEquals( "\"John Doe\"",
                      field.getInitExpr() );
        assertEquals( "50",
                      field.getAnnotation( "length" ).getValue( "max" ) );
        assertNotNull( field.getAnnotation( "key" ) );

        field = type.getFields().get( "age" );
        assertEquals( "age",
                      field.getFieldName() );
        assertEquals( "int",
                      field.getPattern().getObjectType() );
        assertEquals( "-1",
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.