Package org.qi4j.runtime.injection

Examples of org.qi4j.runtime.injection.InjectedParametersModel


                                                  Constructor realConstructor,
                                                  Constructor injectedConstructor
    )
    {
        int idx = 0;
        InjectedParametersModel parameters = new InjectedParametersModel();
        Annotation[][] parameterAnnotations = injectedConstructor.getParameterAnnotations();
        for( Type type : injectedConstructor.getGenericParameterTypes() )
        {
            Annotation injectionAnnotation = first(
                filter( Specifications.translate( Annotations.type(), Annotations.hasAnnotation( InjectionScope.class ) ), iterable( parameterAnnotations[ idx ] ) ) );

            if( injectionAnnotation == null )
            {
                if( fragmentClass.getSuperclass().isMemberClass() )
                {
                    injectionAnnotation = new Uses()
                    {
                        @Override
                        public Class<? extends Annotation> annotationType()
                        {
                            return Uses.class;
                        }
                    };
                }
                else
                {
                    return null; // invalid constructor parameter
                }
            }

            boolean optional = DependencyModel.isOptional( injectionAnnotation, parameterAnnotations[ idx ] );

            Type genericType = type;
            if( genericType instanceof ParameterizedType )
            {
                genericType = new ParameterizedTypeInstance( ( (ParameterizedType) genericType ).getActualTypeArguments(), ( (ParameterizedType) genericType )
                    .getRawType(), ( (ParameterizedType) genericType ).getOwnerType() );

                for( int i = 0; i < ( (ParameterizedType) genericType ).getActualTypeArguments().length; i++ )
                {
                    Type typeArg = ( (ParameterizedType) genericType ).getActualTypeArguments()[ i ];
                    if( typeArg instanceof TypeVariable )
                    {
                        typeArg = Classes.resolveTypeVariable( (TypeVariable) typeArg, realConstructor.getDeclaringClass(), fragmentClass );
                        ( (ParameterizedType) genericType ).getActualTypeArguments()[ i ] = typeArg;
                    }
                }
            }

            DependencyModel dependencyModel = new DependencyModel( injectionAnnotation, genericType, fragmentClass, optional,
                                                                   parameterAnnotations[ idx ] );
            parameters.addDependency( dependencyModel );
            idx++;
        }
        return new ConstructorModel( realConstructor, parameters );
    }
View Full Code Here

TOP

Related Classes of org.qi4j.runtime.injection.InjectedParametersModel

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.