com.sun.mirror.declaration.Declaration.getAnnotationMirrors()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(6.7k)|赞(0)|评价(0)|浏览(109)

本文整理了Java中com.sun.mirror.declaration.Declaration.getAnnotationMirrors()方法的一些代码示例,展示了Declaration.getAnnotationMirrors()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Declaration.getAnnotationMirrors()方法的具体详情如下:
包路径:com.sun.mirror.declaration.Declaration
类名称:Declaration
方法名:getAnnotationMirrors

Declaration.getAnnotationMirrors介绍

暂无

代码示例

代码示例来源:origin: stackoverflow.com

Collection<AnnotationMirror> ams = d.getAnnotationMirrors();
for (AnnotationMirror am : ams) {
  if (am.getAnnotationType().getDeclaration().equals(atd)) {

代码示例来源:origin: net.sf.apt-jelly/apt-jelly-core

public Collection<AnnotationMirror> getAnnotationMirrors() {
 return DeclarationDecorator.decorateAnnotationMirrors(delegate.getAnnotationMirrors());
}

代码示例来源:origin: org.andromda.thirdparty.jaxb2_commons/jaxb-xjc

/**
 * Gets all the annotations on the given declaration.
 */
private Annotation[] getAllAnnotations(Declaration decl, Locatable srcPos) {
  List<Annotation> r = new ArrayList<Annotation>();
  for( AnnotationMirror m : decl.getAnnotationMirrors() ) {
    try {
      String fullName = m.getAnnotationType().getDeclaration().getQualifiedName();
      Class<? extends Annotation> type =
        getClass().getClassLoader().loadClass(fullName).asSubclass(Annotation.class);
      Annotation annotation = decl.getAnnotation(type);
      if(annotation!=null)
        r.add( LocatableAnnotation.create(annotation,srcPos) );
    } catch (ClassNotFoundException e) {
      // just continue
    }
  }
  return r.toArray(EMPTY_ANNOTATION);
}

代码示例来源:origin: sun-jaxb/jaxb-xjc

/**
 * Gets all the annotations on the given declaration.
 */
private Annotation[] getAllAnnotations(Declaration decl, Locatable srcPos) {
  List<Annotation> r = new ArrayList<Annotation>();
  for( AnnotationMirror m : decl.getAnnotationMirrors() ) {
    try {
      String fullName = m.getAnnotationType().getDeclaration().getQualifiedName();
      Class<? extends Annotation> type =
        getClass().getClassLoader().loadClass(fullName).asSubclass(Annotation.class);
      Annotation annotation = decl.getAnnotation(type);
      if(annotation!=null)
        r.add( LocatableAnnotation.create(annotation,srcPos) );
    } catch (ClassNotFoundException e) {
      // just continue
    }
  }
  return r.toArray(EMPTY_ANNOTATION);
}

代码示例来源:origin: org.codehaus.enunciate/enunciate-core

public static boolean isFormBeanParameter(Declaration candidate) {
 for (AnnotationMirror annotation : candidate.getAnnotationMirrors()) {
  AnnotationTypeDeclaration declaration = annotation.getAnnotationType().getDeclaration();
  if (declaration != null) {
   String fqn = declaration.getQualifiedName();
   if (FORM_BEAN_ANNOTATIONS.contains(fqn)) {
    return true;
   }
  }
 }
 return false;
}

代码示例来源:origin: org.codehaus.enunciate/enunciate-core

public static boolean isResourceParameter(Declaration candidate) {
 if (!isSystemParameter(candidate)) {
  for (AnnotationMirror annotation : candidate.getAnnotationMirrors()) {
   AnnotationTypeDeclaration declaration = annotation.getAnnotationType().getDeclaration();
   if (declaration != null) {
    String fqn = declaration.getQualifiedName();
    if ((MatrixParam.class.getName().equals(fqn))
     || QueryParam.class.getName().equals(fqn)
     || PathParam.class.getName().equals(fqn)
     || CookieParam.class.getName().equals(fqn)
     || HeaderParam.class.getName().equals(fqn)
     || FormParam.class.getName().equals(fqn)) {
     return true;
    }
    EnunciateConfiguration config = ((EnunciateFreemarkerModel) FreemarkerModel.get()).getEnunciateConfig();
    if (config != null && config.getSystemResourceParameterAnnotations().contains(fqn)) {
     return false;
    }
    if (config != null && config.getCustomResourceParameterAnnotations().contains(fqn)) {
     return true;
    }
   }
  }
 }
 return false;
}

代码示例来源:origin: net.sf.apt-jelly/apt-jelly-core

/**
 * Whether the given declaration is annotated with an annotation that has the given
 * (fully-qualified) annotation name.
 *
 * @param declaration    The declaration.
 * @param annotationName The annotation name.
 * @return Whether the declaration has the annotation.
 */
protected boolean hasAnnotation(D declaration, String annotationName) {
 for (AnnotationMirror mirror : declaration.getAnnotationMirrors()) {
  AnnotationTypeDeclaration annotation = mirror.getAnnotationType().getDeclaration();
  if ((annotation != null) && (annotation.getQualifiedName().equals(annotationName))) {
   return true;
  }
 }
 return false;
}

代码示例来源:origin: org.codehaus.enunciate/enunciate-core

public static boolean isSystemParameter(Declaration candidate) {
 for (AnnotationMirror annotation : candidate.getAnnotationMirrors()) {
  AnnotationTypeDeclaration declaration = annotation.getAnnotationType().getDeclaration();
  if (declaration != null) {
   String fqn = declaration.getQualifiedName();
   if (Context.class.getName().equals(fqn) && candidate.getAnnotation(TypeHint.class) == null) {
    return true;
   }
   EnunciateConfiguration config = ((EnunciateFreemarkerModel) FreemarkerModel.get()).getEnunciateConfig();
   if (config != null && config.getSystemResourceParameterAnnotations().contains(fqn)) {
    return true;
   }
  }
 }
 return false;
}

代码示例来源:origin: net.sf.apt-jelly/apt-jelly-core

@Override
protected void setupModelForLoop(TemplateModel model, D declaration, int index) throws TemplateException {
 super.setupModelForLoop(model, declaration, index);
 if (annotationVar != null) {
  Collection<AnnotationMirror> annotations = getCurrentDeclaration().getAnnotationMirrors();
  for (AnnotationMirror mirror : annotations) {
   AnnotationTypeDeclaration annotation = mirror.getAnnotationType().getDeclaration();
   if (annotation != null) {
    if (annotation.getQualifiedName().equals(this.annotation)) {
     model.setVariable(annotationVar, mirror);
    }
   }
  }
 }
}

代码示例来源:origin: org.codehaus.enunciate/enunciate-core

Collection<AnnotationMirror> annotationMirrors = declaration.getAnnotationMirrors();
for (AnnotationMirror annotationMirror : annotationMirrors) {
 AnnotationType annotationType = annotationMirror.getAnnotationType();

代码示例来源:origin: net.sf.apt-jelly/apt-jelly-core

@Override
public boolean preProcess(B block, TemplateOutput<B> output, TemplateModel model) throws IOException, TemplateException {
 super.preProcess(block, output, model);
 
 if (annotation == null) {
  throw new MissingParameterException("annotation");
 }
 Declaration declaration = getDeclaration();
 if (declaration == null) {
  declaration = getCurrentDeclaration();
  if (declaration == null) {
   throw new MissingParameterException("declaration");
  }
 }
 Collection<AnnotationMirror> annotations = declaration.getAnnotationMirrors();
 for (AnnotationMirror mirror : annotations) {
  AnnotationTypeDeclaration annotationDeclaration = mirror.getAnnotationType().getDeclaration();
  if ((annotationDeclaration != null) && (annotationDeclaration.getQualifiedName().equals(annotation))) {
   if (var != null) {
    model.setVariable(var, mirror);
   }
   return true;
  }
 }
 return false;
}

代码示例来源:origin: net.sf.apt-jelly/apt-jelly-core

for (AnnotationMirror annotationMirror : declaration.getAnnotationMirrors()) {
 AnnotationType annotationType = annotationMirror.getAnnotationType();
 if (annotationType != null) {

代码示例来源:origin: org.codehaus.enunciate/enunciate-core

for (AnnotationMirror annotation : declaration.getAnnotationMirrors()) {
 AnnotationTypeDeclaration decl = annotation.getAnnotationType().getDeclaration();
 if (decl != null) {

相关文章