/** * Resolve the parameter for the expected type. The method will return <code>null</code> * If the expected type is not one of the collection types {@link Array}, * {@link Collection}or {@link Map}. An empty collection is only a valid resolution, if * the <code>emptyCollection</code> flag was set. * * @param container {@inheritDoc} * @param adapter {@inheritDoc} * @param expectedType {@inheritDoc} * @return the instance of the collection type or <code>null</code> * @throws PicoInitializationException {@inheritDoc} */ public Object resolveInstance(PicoContainer container, ComponentAdapter adapter, Class expectedType) { // type check is done in isResolvable Object result = null; final Class collectionType = getCollectionType(expectedType); if (collectionType != null) { final Map adapterMap = getMatchingComponentAdapters(container, adapter, componentKeyType, getValueType(expectedType)); if (Array.class.isAssignableFrom(collectionType)) { result = getArrayInstance(container, expectedType, adapterMap); } else if (Map.class.isAssignableFrom(collectionType)) { result = getMapInstance(container, expectedType, adapterMap); } else if (Collection.class.isAssignableFrom(collectionType)) { result = getCollectionInstance(container, expectedType, adapterMap); } else { throw new PicoIntrospectionException(expectedType.getName() + " is not a collective type"); } } return result; }