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

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

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

MetaClass.getDeclaredFields介绍

暂无

代码示例

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

private static List<MetaField> getAllFields(MetaClass c) {
 ArrayList<MetaField> fields = new ArrayList<MetaField>();
 for (; c != null; c = c.getSuperClass()) {
  fields.addAll(Arrays.asList(c.getDeclaredFields()));
 }
 return fields;
}

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

private static List<MetaField> getAllFields(MetaClass c) {
 ArrayList<MetaField> fields = new ArrayList<MetaField>();
 for (; c != null; c = c.getSuperClass()) {
  fields.addAll(Arrays.asList(c.getDeclaredFields()));
 }
 return fields;
}

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

@Override
public final List<MetaField> getFieldsAnnotatedWith(final Class<? extends Annotation> annotation) {
 final List<MetaField> fields = new ArrayList<>();
 MetaClass scanTarget = this;
 while (scanTarget != null) {
  for (final MetaField m : scanTarget.getDeclaredFields()) {
   if (m.isAnnotationPresent(annotation)) {
    fields.add(m);
   }
  }
  scanTarget = scanTarget.getSuperClass();
 }
 return Collections.unmodifiableList(fields);
}

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

@Override
public final List<MetaField> getFieldsAnnotatedWith(final Class<? extends Annotation> annotation) {
 final List<MetaField> fields = new ArrayList<>();
 MetaClass scanTarget = this;
 while (scanTarget != null) {
  for (final MetaField m : scanTarget.getDeclaredFields()) {
   if (m.isAnnotationPresent(annotation)) {
    fields.add(m);
   }
  }
  scanTarget = scanTarget.getSuperClass();
 }
 return Collections.unmodifiableList(fields);
}

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

@Override
public List<MetaField> getFieldsWithMetaAnnotations(final Class<? extends Annotation> annotation) {
 final List<MetaField> methods = new ArrayList<>();
 MetaClass scanTarget = this;
 while (scanTarget != null) {
  for (final MetaField m : scanTarget.getDeclaredFields()) {
   for (final Annotation a : m.getAnnotations()) {
    if (_findMetaAnnotation(a.annotationType(), annotation)) {
     methods.add(m);
    }
   }
  }
  scanTarget = scanTarget.getSuperClass();
 }
 return methods;
}

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

@Override
public List<MetaField> getFieldsWithMetaAnnotations(final Class<? extends Annotation> annotation) {
 final List<MetaField> methods = new ArrayList<>();
 MetaClass scanTarget = this;
 while (scanTarget != null) {
  for (final MetaField m : scanTarget.getDeclaredFields()) {
   for (final Annotation a : m.getAnnotations()) {
    if (_findMetaAnnotation(a.annotationType(), annotation)) {
     methods.add(m);
    }
   }
  }
  scanTarget = scanTarget.getSuperClass();
 }
 return methods;
}

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

ObjectBuilder(final MetaClass type, final Context context, final CallElementBuilder callElementBuilder) {
 super(context, callElementBuilder);
 if (context != null) {
  context.attachClass(type);
  Arrays.stream(type.getDeclaredFields()).        
   forEach(f -> context.addVariable(Variable.create(f.getName(), f.getType()))); 
 }
 this.type = type;
}

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

/**
 * Checks is the given {@link MetaField} is in scope (part of the attached class contexts).
 *
 * @param field
 *     the field to check.
 *
 * @return true if in scope, otherwise false.
 */
public boolean isInScope(final MetaField field) {
 checkThread();
 Context c = this;
 do {
  for (final MetaClass clazz : c.classContexts) {
   for (final MetaField m : clazz.getDeclaredFields()) {
    if (m.equals(field))
     return true;
   }
  }
 }
 while ((c = c.parent) != null);
 return false;
}

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

/**
 * Checks is the given {@link MetaField} is in scope (part of the attached class contexts).
 *
 * @param field
 *     the field to check.
 *
 * @return true if in scope, otherwise false.
 */
public boolean isInScope(final MetaField field) {
 checkThread();
 Context c = this;
 do {
  for (final MetaClass clazz : c.classContexts) {
   for (final MetaField m : clazz.getDeclaredFields()) {
    if (m.equals(field))
     return true;
   }
  }
 }
 while ((c = c.parent) != null);
 return false;
}

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

ObjectBuilder(final MetaClass type, final Context context, final CallElementBuilder callElementBuilder) {
 super(context, callElementBuilder);
 if (context != null) {
  context.attachClass(type);
  Arrays.stream(type.getDeclaredFields()).        
   forEach(f -> context.addVariable(Variable.create(f.getName(), f.getType()))); 
 }
 this.type = type;
}

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

private void removeLinksToProducedTypes(final InjectableImpl specialized, final Set<InjectableImpl> toBeRemoved) {
 final Collection<InjectableReference> producedReferences = new ArrayList<>();
 for (final MetaMethod method : specialized.type.getDeclaredMethodsAnnotatedWith(Produces.class)) {
  producedReferences.add(lookupInjectableReference(method.getReturnType(), qualFactory.forSource(method)));
 }
 for (final MetaField field : specialized.type.getDeclaredFields()) {
  if (field.isAnnotationPresent(Produces.class)) {
   producedReferences.add(lookupInjectableReference(field.getType(), qualFactory.forSource(field)));
  }
 }
 for (final InjectableReference reference : producedReferences) {
  final Iterator<InjectableBase> linkIter = reference.linked.iterator();
  while (linkIter.hasNext()) {
   final InjectableBase link = linkIter.next();
   if (link instanceof InjectableImpl && ((InjectableImpl) link).injectableType.equals(InjectableType.Producer)) {
    final InjectableImpl concreteLink = (InjectableImpl) link;
    final ProducerInstanceDependencyImpl producerMemberDep = GraphUtil.findProducerInstanceDep(concreteLink);
    if (producerMemberDep.producingMember.getDeclaringClass().equals(specialized.type)) {
     linkIter.remove();
     toBeRemoved.add(concreteLink);
    }
   }
  }
 }
}

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

for (final MetaField metaField : metaClass.getDeclaredFields()) {
 if (metaField.isAnnotationPresent(annotation)) {
  result.add(metaField);
for (final MetaField metaField : metaClass.getDeclaredFields()) {
 if (metaField.isAnnotationPresent(annotation)) {
  result.add(metaField);

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

for (final MetaField metaField : metaClass.getDeclaredFields()) {
 if (metaField.isAnnotationPresent(annotation)) {
  result.add(metaField);
for (final MetaField metaField : metaClass.getDeclaredFields()) {
 if (metaField.isAnnotationPresent(annotation)) {
  result.add(metaField);

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

@Test
public void testGetDeclaredFields() {
 final List<String> expectedFields = Lists.newLinkedList();
 expectedFields.add(Child.class.getCanonicalName() + "." + "childPrivate");
 expectedFields.add(Child.class.getCanonicalName() + "." + "childPackage");
 expectedFields.add(Child.class.getCanonicalName() + "." + "childProtected");
 expectedFields.add(Child.class.getCanonicalName() + "." + "childPublic");
 final ArrayList<String> actualFields = new ArrayList<>();
 for (final MetaField field : getMetaClass(Child.class).getDeclaredFields()) {
  actualFields.add(field.getDeclaringClass().getCanonicalName() + "." + field.getName());
 }
 Collections.sort(expectedFields);
 Collections.sort(actualFields);
 assertEquals(expectedFields.toString(), actualFields.toString());
}

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

if (sCls != null) {
 do {
  for (final MetaField metaField : sCls.getDeclaredFields()) {
   if (!metaField.isPrivate()) {
    context.addVariable(Variable.create(metaField.getName(), metaField.getType()));

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

if (sCls != null) {
 do {
  for (final MetaField metaField : sCls.getDeclaredFields()) {
   if (!metaField.isPrivate()) {
    context.addVariable(Variable.create(metaField.getName(), metaField.getType()));

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

Arrays.stream(type.getDeclaredFields())
    .forEach(field -> context1.addVariable(Variable.create(field.getName(), field.getType())));
buf.append(" {\n").append(extendsBlock.generate(context1)).append("\n}\n");

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

Arrays.stream(type.getDeclaredFields())
    .forEach(field -> context1.addVariable(Variable.create(field.getName(), field.getType())));
buf.append(" {\n").append(extendsBlock.generate(context1)).append("\n}\n");

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

@Test
 public void testGetDeclaredFields() {
  final ClassStructureBuilder<?> classBuilder = ClassBuilder
    .define("Child", Parent.class)
    .publicScope()
    .body()
    .privateField("childPrivate", int.class).finish()
    .packageField("childPackage", int.class).finish()
    .protectedField("childProtected", int.class).finish()
    .publicField("childPublic", int.class).finish();
  final MetaClass child = classBuilder.getClassDefinition();
  final ArrayList<String> fields = new ArrayList<String>();
  for (MetaField field : child.getDeclaredFields()) {
   fields.add(field.getDeclaringClass().getCanonicalName() + "." + field.getName());
  }

  final List<String> expectedFields = Lists.newLinkedList();
  expectedFields.add(child.getCanonicalName() + "." + "childPrivate");
  expectedFields.add(child.getCanonicalName() + "." + "childPackage");
  expectedFields.add(child.getCanonicalName() + "." + "childProtected");
  expectedFields.add(child.getCanonicalName() + "." + "childPublic");

  Collections.sort(fields);
  Collections.sort(expectedFields);

  assertEquals(expectedFields.toString(), fields.toString());
 }
}

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

for (final MetaField field : clazz.getDeclaredFields()) {
 final BuildMetaField bmf = new ShadowBuildMetaField(buildMetaClass, EmptyStatement.INSTANCE,
   GenUtil.scopeOf(field), field.getType(), field.getName(), field);

相关文章