Created
June 7, 2017 06:24
-
-
Save gayanW/2df142a6bddffd59b04b8982c10d1985 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private String getResourceName(DelegatingResourceHandler resourceHandler, boolean getParent) { | |
Resource annotation = resourceHandler.getClass().getAnnotation(Resource.class); | |
String resourceName = null; | |
if (annotation != null) { | |
// top level resource | |
resourceName = annotation.name(); | |
} else { | |
// sub resource | |
SubResource subResourceAnnotation = resourceHandler.getClass().getAnnotation(SubResource.class); | |
if (subResourceAnnotation != null) { | |
if (getParent) { | |
Resource parentResourceAnnotation = subResourceAnnotation.parent().getAnnotation(Resource.class); | |
resourceName = parentResourceAnnotation.name(); | |
} else { | |
resourceName = subResourceAnnotation.path(); | |
} | |
} | |
} | |
return resourceName; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment