private static RetentionPolicy getRetentionPolicy(
Class<? extends java.lang.annotation.Annotation> clazz) {
// Default retention policy is CLASS, see @Retention.
RetentionPolicy retentionPolicy = RetentionPolicy.CLASS;
Retention retentionAnnotation = clazz.getAnnotation(Retention.class);
if (retentionAnnotation != null) {
retentionPolicy = retentionAnnotation.value();
}
return retentionPolicy;
}