if (RecordTemplate.class.isAssignableFrom(keyClass))
{
// a complex key is being used and thus ComplexKeyResource should be implemented so that we can wrap it in a
// ComplexResourceKey
throw new ResourceConfigException("Class '" + collectionResourceClass.getName() +
"' should implement 'ComplexKeyResource' as a complex key '" +
keyClass.getName() + "' is being used.");
}
else if (TyperefInfo.class.isAssignableFrom(keyClass))
{
throw new ResourceConfigException("Typeref '" + keyClass.getName() + "' cannot be key type for class '" +
collectionResourceClass.getName() + "'.");
}
if (keyClass.equals(ComplexResourceKey.class))
{
@SuppressWarnings("unchecked")
Type[] typeArguments = ((ParameterizedType)actualTypeArguments.get(0)).getActualTypeArguments();
keyKeyClass = ReflectionUtils.getClass(typeArguments[0]).asSubclass(RecordTemplate.class);
keyParamsClass = ReflectionUtils.getClass(typeArguments[1]).asSubclass(RecordTemplate.class);
}
valueClass = ReflectionUtils.getClass(actualTypeArguments.get(1)).asSubclass(RecordTemplate.class);
}
ResourceType resourceType = getResourceType(collectionResourceClass);
RestLiAnnotationData annotationData;
if (collectionResourceClass.isAnnotationPresent(RestLiCollection.class))
{
annotationData =
new RestLiAnnotationData(collectionResourceClass.getAnnotation(RestLiCollection.class));
}
else if (collectionResourceClass.isAnnotationPresent(RestLiAssociation.class))
{
annotationData =
new RestLiAnnotationData(collectionResourceClass.getAnnotation(RestLiAssociation.class));
}
else
{
throw new ResourceConfigException("No valid annotation on resource class '"
+ collectionResourceClass.getName() + "'");
}
String name = annotationData.name();
String namespace = annotationData.namespace();