use of com.linkedin.restli.server.annotations.RestLiSimpleResource in project rest.li by linkedin.
the class RestLiAnnotationReader method getResourceType.
private static ResourceType getResourceType(final Class<?> resourceClass) {
RestLiCollection collAnno = resourceClass.getAnnotation(RestLiCollection.class);
RestLiAssociation assocAnno = resourceClass.getAnnotation(RestLiAssociation.class);
RestLiSimpleResource simpleResourceAnno = resourceClass.getAnnotation(RestLiSimpleResource.class);
if (resourceClass.isAnnotationPresent(RestLiActions.class)) {
throw new ResourceConfigException("Resource class '" + resourceClass.getName() + "' cannot have both @RestLiCollection and @RestLiActions annotations.");
}
int annoCount = 0;
annoCount += collAnno != null ? 1 : 0;
annoCount += assocAnno != null ? 1 : 0;
annoCount += simpleResourceAnno != null ? 1 : 0;
if (annoCount > 1) {
throw new ResourceConfigException("Class '" + resourceClass.getName() + "' is annotated " + "with too many RestLi annotations");
} else if (collAnno != null) {
return ResourceType.COLLECTION;
} else if (assocAnno != null) {
return ResourceType.ASSOCIATION;
} else if (simpleResourceAnno != null) {
return ResourceType.SIMPLE;
} else {
throw new ResourceConfigException("Class '" + resourceClass.getName() + "' should be annotated " + "with '" + RestLiAssociation.class.getName() + "'" + " or '" + RestLiCollection.class.getName() + "'" + " or '" + RestLiSimpleResource.class.getName() + "'");
}
}
Aggregations