protected Array<Object> createComponents(final PooledList<Constructor> constructors,
            final Array<Initiated> componentsToInitiate) throws Exception {
        final Array<Object> components = GdxArrays.newArray();
        for (int index = 0, iterations = getIterationsAmount(); constructors.isNotEmpty()
                && index < iterations; index++) {
            for (final Constructor constructor : constructors) {
                final Object component;
                if (constructor.getParameterTypes().length == 0) {
                    component = constructor.newInstance(Providers.EMPTY_ARRAY);
                } else {
                    final Class<?>[] parameterTypes = constructor.getParameterTypes();
                    if (isAnyProviderMissing(parameterTypes)) {
                        continue;
                    }
                    component = createObject(constructor, parameterTypes);
                }
                processScannedComponent(component, componentsToInitiate);
                components.add(component);
                constructors.remove();
            }
        }
        if (!constructors.isEmpty()) {
            if (isFailIfUnknownType()) {
                final Array<String> classNames = GdxArrays.newArray();
                for (final Constructor constructor : constructors) {
                    classNames.add(constructor.getDeclaringClass().getName());
                }
                throw new RuntimeException(
                        "Unknown or circular dependencies detected. Unable to create instances of: " + classNames);
            }
            for (final Constructor constructor : constructors) {
                final Object component = createObject(constructor, constructor.getParameterTypes());
                processScannedComponent(component, componentsToInitiate);
                components.add(component);
            }
        }
        return components;
    }
protected Array < Object > createComponents ( final PooledList < Constructor > constructors , final Array < Initiated > componentsToInitiate ) throws Exception { final Array < Object > components = GdxArrays . newArray ( ) ; for ( int index = 0 , iterations = getIterationsAmount ( ) ; constructors . isNotEmpty ( ) && index < iterations ; index ++ ) { for ( final Constructor constructor : constructors ) { final Object component ; if ( constructor . getParameterTypes ( ) . length == 0 ) { component = constructor . newInstance ( Providers . EMPTY_ARRAY ) ; } else { final Class < ? > [ ] parameterTypes = constructor . getParameterTypes ( ) ; if ( isAnyProviderMissing ( parameterTypes ) ) { continue ; } component = createObject ( constructor , parameterTypes ) ; } processScannedComponent ( component , componentsToInitiate ) ; components . add ( component ) ; constructors . remove ( ) ; } } if ( ! constructors . isEmpty ( ) ) { if ( isFailIfUnknownType ( ) ) { final Array < String > classNames = GdxArrays . newArray ( ) ; for ( final Constructor constructor : constructors ) { classNames . add ( constructor . getDeclaringClass ( ) . getName ( ) ) ; } throw new RuntimeException ( "Unknown or circular dependencies detected. Unable to create instances of: " + classNames ) ; } for ( final Constructor constructor : constructors ) { final Object component = createObject ( constructor , constructor . getParameterTypes ( ) ) ; processScannedComponent ( component , componentsToInitiate ) ; components . add ( component ) ; } } return components ; }
@param constructors list of gathered constructors of classes to initiate.
@param componentsToInitiate a reference to sorting collection of components to initiate. Should be filled.
@return list of constructed components.
@throws Exception due to reflection issues.