org.jboss.errai.codegen.meta.MetaClass.getFieldsAnnotatedWith()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(4.4k)|赞(0)|评价(0)|浏览(100)

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

MetaClass.getFieldsAnnotatedWith介绍

[英]Returns all declared and inherited fields on this class that have the given annotation targeting them.
[中]返回此类上所有声明的和继承的字段,这些字段具有针对它们的给定注释。

代码示例

代码示例来源:origin: errai/errai

@SuppressWarnings({ "unchecked", "rawtypes" })
private List<HasAnnotations> getAnnotatedWithForElementType(final MetaClass type, final ElementType elemType, final Class<? extends Annotation> annoType) {
 final List annotatedItems;
 switch (elemType) {
 case FIELD:
  annotatedItems = type.getFieldsAnnotatedWith(annoType);
  break;
 case METHOD:
  annotatedItems = type.getMethodsAnnotatedWith(annoType);
  break;
 case PARAMETER:
  annotatedItems = type.getParametersAnnotatedWith(annoType);
  break;
 case TYPE:
  annotatedItems = (type.isAnnotationPresent(annoType)) ? Collections.singletonList(type) : Collections.emptyList();
  break;
 default:
  throw new RuntimeException("Not yet implemented.");
 }
 return annotatedItems;
}

代码示例来源:origin: errai/errai

/**
 * @param producerInjectable If null then only static fields will be processed.
 */
private void processProducerFields(final Injectable producerInjectable, final MetaClass producerType,
    final DependencyGraphBuilder builder, final Collection<MetaMethod> disposesMethods, final boolean enabled,
    final List<String> problems) {
 final boolean staticOnly = (producerInjectable == null);
 final Collection<Class<? extends Annotation>> producerAnnos = injectionContext.getAnnotationsForElementType(WiringElementType.ProducerElement);
 for (final Class<? extends Annotation> producerAnno : producerAnnos) {
  final List<MetaField> fields = producerType.getFieldsAnnotatedWith(producerAnno);
  for (final MetaField field : fields) {
   if (!staticOnly || field.isStatic()) {
    processProducerField(producerInjectable, producerType, builder, disposesMethods, field, enabled, problems);
   }
  }
 }
}

代码示例来源:origin: errai/errai

annotated.addAll(enclosingType.getFieldsAnnotatedWith(annoType));

代码示例来源:origin: org.jboss.errai/errai-data-binding

annotated.addAll(enclosingType.getFieldsAnnotatedWith(annoType));

代码示例来源:origin: errai/errai

return false;
final List<MetaField> producerFields = type.getFieldsAnnotatedWith(producerAnnoType);
if (!producerFields.isEmpty() && producerFields.stream().anyMatch(field -> !field.isStatic())) {
 return false;
if (!type.getFieldsAnnotatedWith(anno).isEmpty()) {
 return false;

代码示例来源:origin: errai/errai

private void addFieldInjectionPoints(final Injectable typeInjectable, final DependencyGraphBuilder builder, final List<String> problems) {
 final boolean noPublicFieldsAllowed = typeInjectable.getWiringElementTypes().contains(WiringElementType.NormalScopedBean);
 final MetaClass type = typeInjectable.getInjectedType();
 final Collection<Class<? extends Annotation>> injectAnnotations = injectionContext.getAnnotationsForElementType(WiringElementType.InjectionPoint);
 for (final Class<? extends Annotation> inject : injectAnnotations) {
  for (final MetaField field : type.getFieldsAnnotatedWith(inject)) {
   if (noPublicFieldsAllowed && field.isPublic()) {
    problems.add("The normal scoped bean " + type.getFullyQualifiedName() + " has a public field " + field.getName());
   }
   builder.addFieldDependency(typeInjectable, field.getType(), qualFactory.forSink(field), field);
  }
 }
}

代码示例来源:origin: org.jboss.errai/errai-data-binding

final List<MetaField> modelFields = decorable.getDecorableDeclaringType().getFieldsAnnotatedWith(Model.class);
if (!modelFields.isEmpty()) {
 throw new GenerationException("Found one or more fields annotated with @Model but missing @Inject "

代码示例来源:origin: errai/errai

final List<MetaField> modelFields = decorable.getDecorableDeclaringType().getFieldsAnnotatedWith(Model.class);
if (!modelFields.isEmpty()) {
 throw new GenerationException("Found one or more fields annotated with @Model but missing @Inject "

代码示例来源:origin: errai/errai

for (MetaField field : pageClass.getFieldsAnnotatedWith(PageState.class)) {
 PageState psAnno = field.getAnnotation(PageState.class);
 String fieldName = field.getName();

代码示例来源:origin: org.jboss.errai/errai-navigation

for (MetaField field : pageClass.getFieldsAnnotatedWith(PageState.class)) {
 PageState psAnno = field.getAnnotation(PageState.class);
 String fieldName = field.getName();

相关文章