}
final Object methodActualTypeArgument = methodActualTypeArguments[0];
if (methodActualTypeArgument instanceof Class) {
final Class<?> actualType = (Class<?>) methodActualTypeArgument;
FacetUtil.addFacet(new TypeOfFacetInferredFromGenerics(actualType, processMethodContext.getFacetHolder(), getSpecificationLoader()));
return;
}
if (methodActualTypeArgument instanceof TypeVariable) {
TypeVariable<?> methodTypeVariable = (TypeVariable<?>) methodActualTypeArgument;
final GenericDeclaration methodGenericClassDeclaration = methodTypeVariable.getGenericDeclaration();
// try to match up with the actual type argument of the generic superclass.
final Type genericSuperclass = processMethodContext.getCls().getGenericSuperclass();
if(genericSuperclass instanceof ParameterizedType) {
final ParameterizedType parameterizedTypeOfSuperclass = (ParameterizedType)genericSuperclass;
if(parameterizedTypeOfSuperclass.getRawType() == methodGenericClassDeclaration) {
final Type[] genericSuperClassActualTypeArguments = parameterizedTypeOfSuperclass.getActualTypeArguments();
// simplification: if there's just one, then use it.
if(methodActualTypeArguments.length == 1) {
final Type actualType = genericSuperClassActualTypeArguments[0];
if(actualType instanceof Class) {
// just being safe
Class<?> actualCls = (Class<?>) actualType;
FacetUtil.addFacet(new TypeOfFacetInferredFromGenerics(actualCls, processMethodContext.getFacetHolder(), getSpecificationLoader()));
return;
}
}
}
}