java类java.lang.annotation.Target的实例源码

RDFProperty.java 文件源码 项目:anno4j 阅读 20 收藏 0 点赞 0 评论 0
private void annotationHeader(JavaMessageBuilder builder)
        throws ObjectStoreConfigException {
    String pkg = builder.getPackageName(this.getURI());
    String simple = builder.getSimpleName(this.getURI());
    if (pkg == null) {
        builder.imports(simple);
    } else {
        builder.pkg(pkg);
        builder.imports(pkg + '.' + simple);
    }
    builder.comment(this);
    if (this.isA(OWL.DEPRECATEDPROPERTY)) {
        builder.annotate(Deprecated.class);
    }
    builder.annotateEnum(Retention.class, "value", RetentionPolicy.class, "RUNTIME");
    builder.annotateEnums(Target.class, "value", ElementType.class, "TYPE", "METHOD",
                "PARAMETER", "ANNOTATION_TYPE", "PACKAGE");
    builder.annotationName(simple);
    builder.annotationProperties(this);
    builder.annotateURI(Iri.class, "value", builder.getType(this.getURI()));
    if (this.isA(OWL.FUNCTIONALPROPERTY)) {
        builder.method("value", true).returnType(builder.imports(String.class)).end();
    } else {
        builder.method("value", true).returnType(builder.imports(String.class) + "[]")
                .end();
    }
}
LocalTransformation.java 文件源码 项目:asteroid 阅读 22 收藏 0 点赞 0 评论 0
private AnnotationNode getTargetAnnotation(final String resolvedTarget) {
    final List<ElementType> types = resolveAnnotationTarget(resolvedTarget);
    final ListExpression listExpr = resolveTargetFromElementType(types);

    return A.NODES.annotation(Target.class)
            .member(A.UTIL.ANNOTATION.ANNOTATION_VALUE, listExpr)
            .build();
}
IndexFileWriter.java 文件源码 项目:annotation-tools 阅读 27 收藏 0 点赞 0 评论 0
private Collection<Annotation> requiredMetaannotations(
        Collection<Annotation> annos) {
    Set<Annotation> results = new HashSet<Annotation>();
    for (Annotation a : annos) {
        String aName = a.def.name;
        if (aName.equals(Retention.class.getCanonicalName())
            || aName.equals(Target.class.getCanonicalName())) {
            results.add(a);
        }
    }
    return results;
}
Annotations.java 文件源码 项目:Stdlib 阅读 42 收藏 0 点赞 0 评论 0
/**
 * Returns a set of meta annotations associated with the given annotation
 * bundle. This will suppress {@link java.lang.annotation.Retention} and
 * {@link java.lang.annotation.Target}. The supplied annotation will be
 * the first annotation included in the returned set.
 */
public static Set<Annotation> getMetaAnnotations(Annotation bundle)
{
   Set<Annotation> result = Sets.newLinkedHashSet();
   result.add(Objects.notNull(bundle));
   for (Annotation a : bundle.annotationType().getDeclaredAnnotations()) {
      // minor optimization: by-pass 2 common JDK meta-annotations
      if ((a instanceof Target) || (a instanceof Retention)) {
         continue;
      }
      result.add(a);
   }
   return result;
}
ClassDepsParserTest.java 文件源码 项目:jadecy 阅读 21 收藏 0 点赞 0 评论 0
public void test_computeDependencies_fromAno_public() {
    for (boolean apiOnly : FALSE_TRUE) {

        final SortedSet<String> expected = new TreeSet<String>();
        //
        // Extends Object.
        addSlashedName(expected, Object.class);
        // Implements Annotation.
        addSlashedName(expected, Annotation.class);
        //
        addSlashedName(expected, Class.class);
        addSlashedName(expected, Number.class);
        addSlashedName(expected, Byte.class);
        addSlashedName(expected, String.class);
        addSlashedName(expected, RoundingMode.class);
        addSlashedName(expected, Documented.class);
        //
        if (apiOnly) {
        } else {
            addSlashedName(expected, Retention.class);
            addSlashedName(expected, RetentionPolicy.class);
            addSlashedName(expected, Target.class);
            addSlashedName(expected, ElementType.class);
            //
            addSlashedName(expected, ClassDepsParserTest.class);
        }

        computeDepsAndCheck(MyTestAnno2_public.class.getName(), apiOnly, expected);
    }
}
ClassDepsParserTest.java 文件源码 项目:jadecy 阅读 22 收藏 0 点赞 0 评论 0
public void test_computeDependencies_fromAno_private() {
    for (boolean apiOnly : FALSE_TRUE) {

        final SortedSet<String> expected = new TreeSet<String>();
        //
        if (apiOnly) {
        } else {
            addSlashedName(expected, Retention.class);
            addSlashedName(expected, RetentionPolicy.class);
            addSlashedName(expected, Target.class);
            addSlashedName(expected, ElementType.class);
            //
            addSlashedName(expected, ClassDepsParserTest.class);
            //
            addSlashedName(expected, Object.class);
            addSlashedName(expected, Annotation.class);
            //
            addSlashedName(expected, Class.class);
            addSlashedName(expected, Number.class);
            addSlashedName(expected, Byte.class);
            addSlashedName(expected, String.class);
            addSlashedName(expected, RoundingMode.class);
            addSlashedName(expected, Documented.class);
        }

        computeDepsAndCheck(MyTestAnno2_private.class.getName(), apiOnly, expected);
    }
}
AnnotationProcessorPico.java 文件源码 项目:picoservice 阅读 21 收藏 0 点赞 0 评论 0
private boolean _isValidElement(Element pElement)
{
  Retention retention = pElement.getAnnotation(Retention.class);
  if (retention == null || retention.value() != RetentionPolicy.RUNTIME)
  {
    processingEnv.getMessager().printMessage(Diagnostic.Kind.MANDATORY_WARNING, "Retention should be RUNTIME", pElement);
    return false;
  }
  Target target = pElement.getAnnotation(Target.class);
  if (target == null || target.value() == null || target.value().length == 0)
  {
    processingEnv.getMessager().printMessage(Diagnostic.Kind.MANDATORY_WARNING, "Target has to be defined", pElement);
    return false;
  }
  else
  {
    for (ElementType elementType : target.value())
    {
      if (elementType != ElementType.TYPE)
      {
        processingEnv.getMessager().printMessage(Diagnostic.Kind.MANDATORY_WARNING, "Unsupported type: " + elementType, pElement);
        return false;
      }
    }
  }
  return true;
}
TestFromListOf.java 文件源码 项目:jfixture 阅读 24 收藏 0 点赞 0 评论 0
@Test
public void Annotation_can_only_be_applied_to_fields() {
    Target target = FromListOf.class.getAnnotation(Target.class);
    assertEquals(1, target.value().length);
    ElementType type = target.value()[0];
    assertTrue(type.equals(ElementType.FIELD));
}
TestRange.java 文件源码 项目:jfixture 阅读 20 收藏 0 点赞 0 评论 0
@Test
public void Annotation_can_only_be_applied_to_fields() {
    Target target = Range.class.getAnnotation(Target.class);
    assertEquals(1, target.value().length);
    ElementType type = target.value()[0];
    assertTrue(type.equals(ElementType.FIELD));
}
TestFixture.java 文件源码 项目:jfixture 阅读 24 收藏 0 点赞 0 评论 0
@Test
public void Annotation_can_only_be_applied_to_fields() {
    Target target = Fixture.class.getAnnotation(Target.class);
    assertEquals(1, target.value().length);
    ElementType type = target.value()[0];
    assertTrue(type.equals(ElementType.FIELD));
}


问题


面经


文章

微信
公众号

扫码关注公众号