in webbeans-impl/src/main/java/org/apache/webbeans/util/GenericsUtil.java [358:408]
private static boolean isAssignableFrom(boolean isDelegateOrEvent, ParameterizedType injectionPointType, ParameterizedType beanType,
Map<Type, Integer> visited)
{
if (injectionPointType.getRawType() != beanType.getRawType())
{
return false;
}
boolean swapParams = !isDelegateOrEvent;
Type[] injectionPointTypeArguments = injectionPointType.getActualTypeArguments();
Type[] beanTypeArguments = beanType.getActualTypeArguments();
for (int i = 0; i < injectionPointTypeArguments.length; i++)
{
Type injectionPointTypeArgument = injectionPointTypeArguments[i];
Type beanTypeArgument = beanTypeArguments[i];
// for this special case it's actually an 'assignable to', thus we swap the params, see CDI-389
// but this special rule does not apply to Delegate injection points...
if (swapParams &&
(injectionPointTypeArgument instanceof Class || injectionPointTypeArgument instanceof TypeVariable) &&
beanTypeArgument instanceof TypeVariable)
{
Type[] bounds = ((TypeVariable<?>) beanTypeArgument).getBounds();
boolean isNotBound = isNotBound(bounds);
if (!isNotBound)
{
for (Type upperBound : bounds)
{
if (!isAssignableFrom(true, false, upperBound, injectionPointTypeArgument, visited))
{
return false;
}
}
}
}
else if (swapParams && injectionPointTypeArgument instanceof TypeVariable)
{
return false;
}
else if (isDelegateOrEvent && injectionPointTypeArgument instanceof Class && beanTypeArgument instanceof Class)
{
// if no wildcard type was given then we require a real exact match.
return injectionPointTypeArgument.equals(beanTypeArgument);
}
else if (!isAssignableFrom(isDelegateOrEvent, false, injectionPointTypeArgument, beanTypeArgument, visited))
{
return false;
}
}
return true;
}