@SuppressWarnings({"unchecked", "rawtypes"})
@Override
protected void configure()
{
Collection<ComponentAdapter<?>> adapters = delegate.getComponentAdapters();
Binder binder = binder();
for (ComponentAdapter<?> adapter : adapters)
{
Object key = adapter.getComponentKey();
Class<?> type;
Annotation annotation = null;
Class<? extends Annotation> annotationType = null;
if (key instanceof Class<?> && !((Class<?>)key).isAnnotation())
{
type = (Class<?>)key;
}
else
{
if (key instanceof String)
{
annotation = Names.named((String)key);
}
else if (key instanceof Class<?>)
{
annotationType = (Class<? extends Annotation>)key;
}
type = adapter.getComponentImplementation();
}
if (annotation == null && annotationType == null)
{
binder.bind(type).toProvider(new ComponentAdapterProvider(type, adapter));
}
else
{
// As we don't know the type, we will bind it for each super classes and interfaces too
ComponentAdapterProvider provider = new ComponentAdapterProvider(type, adapter);