Package org.drools.compiler.compiler

Examples of org.drools.compiler.compiler.AnnotationDeclarationError


    private void normalizeAnnotations(AnnotatedBaseDescr annotationsContainer, TypeResolver typeResolver, boolean isStrict) {
        for (AnnotationDescr annotationDescr : annotationsContainer.getAnnotations()) {
            annotationDescr.setResource(annotationsContainer.getResource());
            annotationDescr.setStrict(isStrict);
            if (annotationDescr.isDuplicated()) {
                addBuilderResult(new AnnotationDeclarationError(annotationDescr,
                                                                "Duplicated annotation: " + annotationDescr.getName()));
            }
            if (isStrict) {
                normalizeStrictAnnotation(typeResolver, annotationDescr);
            } else {
View Full Code Here


            for ( String key : annotationDescr.getValueMap().keySet() ) {
                try {
                    Method m = annotationClass.getMethod( key );
                    Object val = annotationDescr.getValue( key );
                    if ( val instanceof Object[] && ! m.getReturnType().isArray() ) {
                        addBuilderResult( new AnnotationDeclarationError( annotationDescr,
                                                                          "Wrong cardinality on property " + key ) );
                        return annotationDescr;
                    }
                    if ( m.getReturnType().isArray() && ! (val instanceof Object[]) ) {
                        val = new Object[] { val };
                        annotationDescr.setKeyValue( key, val );
                    }

                    if ( m.getReturnType().isArray() ) {
                        int n = Array.getLength(val);
                        for ( int j = 0; j < n; j++ ) {
                            if ( Class.class.equals( m.getReturnType().getComponentType() ) ) {
                                String className = Array.get( val, j ).toString().replace( ".class", "" );
                                Array.set( val, j, typeResolver.resolveType( className ).getName() + ".class" );
                            } else if ( m.getReturnType().getComponentType().isAnnotation() ) {
                                Array.set( val, j, normalizeAnnotation( typeResolver,
                                                                        (AnnotationDescr) Array.get( val, j ) ) );
                            }
                        }
                    } else {
                        if ( Class.class.equals( m.getReturnType() ) ) {
                            String className = annotationDescr.getValueAsString(key).replace( ".class", "" );
                            annotationDescr.setKeyValue( key, typeResolver.resolveType( className ).getName() + ".class" );
                        } else if ( m.getReturnType().isAnnotation() ) {
                            annotationDescr.setKeyValue( key,
                                                         normalizeAnnotation( typeResolver,
                                                                              (AnnotationDescr) annotationDescr.getValue( key ) ) );
                        }
                    }
                } catch ( NoSuchMethodException e ) {
                    addBuilderResult( new AnnotationDeclarationError( annotationDescr,
                                                                      "Unknown annotation property " + key ) );
                } catch ( ClassNotFoundException e ) {
                    addBuilderResult( new AnnotationDeclarationError( annotationDescr,
                                                                      "Unknown class " + annotationDescr.getValue( key ) +                                                                      " used in property " + key +
                                                                      " of annotation " + annotationDescr.getName() ) );
                } catch ( NoClassDefFoundError e ) {
                    addBuilderResult( new AnnotationDeclarationError( annotationDescr,
                                                                      "Unknown class " + annotationDescr.getValue( key ) +                                                                      " used in property " + key +
                                                                      " of annotation " + annotationDescr.getName() ) );
                }

            }
View Full Code Here

    private void normalizeStrictAnnotation(TypeResolver typeResolver, AnnotationDescr annotationDescr) {
        try {
            Class<?> annotationClass = typeResolver.resolveType(annotationDescr.getName(), TypeResolver.ONLY_ANNOTATION_CLASS_FILTER);
            annotationDescr.setFullyQualifiedName(annotationClass.getCanonicalName());
        } catch (ClassNotFoundException e) {
            addBuilderResult(new AnnotationDeclarationError(annotationDescr,
                                                            "Unknown annotation: " + annotationDescr.getName()));
        } catch (NoClassDefFoundError e) {
            addBuilderResult(new AnnotationDeclarationError(annotationDescr,
                                                            "Unknown annotation: " + annotationDescr.getName()));
        }
    }
View Full Code Here

TOP

Related Classes of org.drools.compiler.compiler.AnnotationDeclarationError

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.