コード例 #1
0
  public boolean hasRuntimeRetention() {
    Map<String, ? extends AnnotationMirror> types =
        getHelper().getAnnotationsByType(getElement().getAnnotationMirrors());
    AnnotationMirror retention = types.get(Retention.class.getCanonicalName());
    if (retention == null) {
      handleNoRetention();
      return false;
    }

    AnnotationParser parser = AnnotationParser.create(getHelper());
    parser.expectEnumConstant(
        AnnotationUtil.VALUE,
        getHelper().resolveType(RetentionPolicy.class.getCanonicalName()),
        null);

    String retentionPolicy = parser.parse(retention).get(AnnotationUtil.VALUE, String.class);
    return RetentionPolicy.RUNTIME.toString().equals(retentionPolicy);
  }