public void handle()

in commons-digester3-core/src/main/java/org/apache/commons/digester3/annotations/handlers/ObjectCreateHandler.java [40:70]


    public void handle( final ObjectCreate annotation, final AnnotatedElement element, final RulesBinder rulesBinder )
    {
        Class<?> type;
        if ( element instanceof Class<?> )
        {
            type = (Class<?>) element;
        }
        else if ( element instanceof Constructor<?> )
        {
            type = ( (Constructor<?>) element ).getDeclaringClass();
        }
        else
        {
            rulesBinder.addError( "Misplaced @ObjectCreate annotation to %s, Class and Constructor only supported",
                                  element );
            return;
        }

        final ObjectCreateBuilder builder = rulesBinder
                .forPattern( annotation.pattern() )
                .withNamespaceURI( annotation.namespaceURI() )
                .createObject()
                .ofType( type )
                .ofTypeSpecifiedByAttribute( annotation.attributeName() != null ? annotation.attributeName() : null );

        if ( element instanceof Constructor<?> )
        {
            final Constructor<?> method = (Constructor<?>) element;
            builder.usingConstructor( method.getParameterTypes() );
        }
    }