当前位置: 首页>>代码示例>>Java>>正文


Java AnnotatedConstruct类代码示例

本文整理汇总了Java中javax.lang.model.AnnotatedConstruct的典型用法代码示例。如果您正苦于以下问题:Java AnnotatedConstruct类的具体用法?Java AnnotatedConstruct怎么用?Java AnnotatedConstruct使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


AnnotatedConstruct类属于javax.lang.model包,在下文中一共展示了AnnotatedConstruct类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: copyDocumentedAnnotations

import javax.lang.model.AnnotatedConstruct; //导入依赖的package包/类
static void copyDocumentedAnnotations( @Nonnull final AnnotatedConstruct element,
                                       @Nonnull final MethodSpec.Builder builder )
{
  for ( final AnnotationMirror annotation : element.getAnnotationMirrors() )
  {
    final DeclaredType annotationType = annotation.getAnnotationType();
    if ( !annotationType.toString().startsWith( "react4j.annotations." ) &&
         null != annotationType.asElement().getAnnotation( Documented.class ) )
    {
      builder.addAnnotation( AnnotationSpec.get( annotation ) );
    }
  }
}
 
开发者ID:react4j,项目名称:react4j,代码行数:14,代码来源:ProcessorUtil.java

示例2: getOrigin

import javax.lang.model.AnnotatedConstruct; //导入依赖的package包/类
@Override @DefinedBy(Api.LANGUAGE_MODEL)
public Origin getOrigin(AnnotatedConstruct c, AnnotationMirror a) {
    Compound ac = cast(Compound.class, a);
    if (ac.isSynthesized())
        return Origin.MANDATED;
    return Origin.EXPLICIT;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:8,代码来源:JavacElements.java

示例3: getAnnotation

import javax.lang.model.AnnotatedConstruct; //导入依赖的package包/类
/**
 * Get a specific annotation mirror from an annotated construct.
 */
static AnnotationMirror getAnnotation(AnnotatedConstruct e, String name) {
    for (AnnotationMirror m: e.getAnnotationMirrors()) {
        TypeElement te = (TypeElement) m.getAnnotationType().asElement();
        if (te.getQualifiedName().contentEquals(name)) {
            return m;
        }
    }
    return null;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:13,代码来源:BasicAnnoTests.java

示例4: copyDocumentedAnnotations

import javax.lang.model.AnnotatedConstruct; //导入依赖的package包/类
static void copyDocumentedAnnotations( @Nonnull final AnnotatedConstruct element,
                                       @Nonnull final MethodSpec.Builder builder )
{
  for ( final AnnotationMirror annotation : element.getAnnotationMirrors() )
  {
    final DeclaredType annotationType = annotation.getAnnotationType();
    if ( !annotationType.toString().startsWith( "arez.annotations." ) &&
         null != annotationType.asElement().getAnnotation( Documented.class ) )
    {
      builder.addAnnotation( AnnotationSpec.get( annotation ) );
    }
  }
}
 
开发者ID:arez,项目名称:arez,代码行数:14,代码来源:ProcessorUtil.java

示例5: of

import javax.lang.model.AnnotatedConstruct; //导入依赖的package包/类
/** Create {@link ClassType} based on {@link javax.lang.model.type.DeclaredType} instance. */
static ClassType of(javax.lang.model.type.DeclaredType type) {
  ClassType classType = new ClassType();
  // extract package name
  Element packageElement = type.asElement();
  while (packageElement.getKind() != ElementKind.PACKAGE) {
    packageElement = packageElement.getEnclosingElement();
  }
  PackageElement casted = (PackageElement) packageElement;
  classType.setPackageName(casted.getQualifiedName().toString());
  // extract simple names and type arguments
  TypeMirror actualType = type;
  for (Element element = type.asElement();
      element.getKind().isClass() || element.getKind().isInterface();
      element = element.getEnclosingElement()) {
    ClassName name = new ClassName(); // annotate(new ClassName(), element); // element.asType());
    name.setName(element.getSimpleName().toString());
    classType.getNames().add(0, name);
    if ((actualType instanceof javax.lang.model.type.DeclaredType)) {
      javax.lang.model.type.DeclaredType dt = (javax.lang.model.type.DeclaredType) actualType;
      annotate(name, dt);
      for (TypeMirror ta : dt.getTypeArguments()) {
        AnnotatedConstruct annotatedConstruct = ta;
        if (ta instanceof javax.lang.model.type.DeclaredType) {
          annotatedConstruct = ((javax.lang.model.type.DeclaredType) ta).asElement();
        }
        JavaType javaType = annotate(JavaMirrors.of(ta), annotatedConstruct);
        name.getTypeArguments().add(TypeArgument.of(javaType));
      }
      actualType = dt.getEnclosingType();
    }
  }
  return classType;
}
 
开发者ID:sormuras,项目名称:listing,代码行数:35,代码来源:JavaMirrors.java

示例6: toHumanReadableString

import javax.lang.model.AnnotatedConstruct; //导入依赖的package包/类
@Nonnull
public static String toHumanReadableString(@Nonnull AnnotatedConstruct construct) {
    StringBuilderAndState<TypeMirror> state = new StringBuilderAndState<>();

    if (construct instanceof Element) {
        ((Element) construct).accept(toHumanReadableStringElementVisitor, state);
    } else if (construct instanceof TypeMirror) {
        ((TypeMirror) construct).accept(toHumanReadableStringVisitor, state);
    }
    return state.bld.toString();
}
 
开发者ID:revapi,项目名称:revapi,代码行数:12,代码来源:Util.java

示例7: annotate

import javax.lang.model.AnnotatedConstruct; //导入依赖的package包/类
static <A extends Annotatable> A annotate(A target, AnnotatedConstruct source) {
  source.getAnnotationMirrors().forEach(m -> target.addAnnotation(of(m)));
  return target;
}
 
开发者ID:sormuras,项目名称:listing,代码行数:5,代码来源:JavaMirrors.java

示例8: withAnnotation

import javax.lang.model.AnnotatedConstruct; //导入依赖的package包/类
public static <T extends AnnotatedConstruct> Predicate<T> withAnnotation(Class<? extends Annotation> cls) {
  return annotated->annotated.getAnnotation(cls) != null;
}
 
开发者ID:WeTheInternet,项目名称:xapi,代码行数:4,代码来源:ElementUtil.java

示例9: TreeBackedAnnotatedConstruct

import javax.lang.model.AnnotatedConstruct; //导入依赖的package包/类
public TreeBackedAnnotatedConstruct(AnnotatedConstruct underlyingConstruct) {
  this.underlyingConstruct = underlyingConstruct;
}
 
开发者ID:facebook,项目名称:buck,代码行数:4,代码来源:TreeBackedAnnotatedConstruct.java

示例10: getOrigin

import javax.lang.model.AnnotatedConstruct; //导入依赖的package包/类
/**
 * Returns the <em>origin</em> of the given annotation mirror.
 *
 * An annotation mirror is {@linkplain Origin#MANDATED mandated}
 * if it is an implicitly declared <em>container annotation</em>
 * used to hold repeated annotations of a repeatable annotation
 * type.
 *
 * <p>Note that if this method returns {@link Origin#EXPLICIT
 * EXPLICIT} and the annotation mirror was created from a class
 * file, then the element may not, in fact, correspond to an
 * explicitly declared construct in source code. This is due to
 * limitations of the fidelity of the class file format in
 * preserving information from source code. For example, at least
 * some versions of the class file format do not preserve whether
 * an annotation was explicitly declared by the programmer or was
 * implicitly declared as a <em>container annotation</em>.
 *
 * @implSpec The default implementation of this method returns
 * {@link Origin#EXPLICIT EXPLICIT}.
 *
 * @param c the construct the annotation mirror modifies
 * @param a the annotation mirror being examined
 * @return the origin of the given annotation mirror
 * @jls 9.6.3 Repeatable Annotation Types
 * @jls 9.7.5 Multiple Annotations of the Same Type
 * @since 9
 */
default Origin getOrigin(AnnotatedConstruct c,
                         AnnotationMirror a) {
    return Origin.EXPLICIT;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:33,代码来源:Elements.java


注:本文中的javax.lang.model.AnnotatedConstruct类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。