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

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

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

MetaClass.getFields介绍

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

代码示例

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

@Override
public MetaField[] getFields() {
 if (_fieldsCache == null) {
  _fieldsCache = fields.stream().filter(field -> field.isPublic()).toArray(size -> new MetaField[size]);
  if (superClass != null) {
   _fieldsCache = ObjectArrays.concat(_fieldsCache, superClass.getFields(), MetaField.class);
  }
 }
 return _fieldsCache;
}

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

@Override
public MetaField[] getFields() {
 if (_fieldsCache == null) {
  _fieldsCache = fields.stream().filter(field -> field.isPublic()).toArray(size -> new MetaField[size]);
  if (superClass != null) {
   _fieldsCache = ObjectArrays.concat(_fieldsCache, superClass.getFields(), MetaField.class);
  }
 }
 return _fieldsCache;
}

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

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

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

@Test
public void testGetFields() {
 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.getFields()) {
  fields.add(field.getDeclaringClass().getCanonicalName() + "." + field.getName());
 }
 final List<String> expectedFields = Lists.newLinkedList();
 expectedFields.add(child.getCanonicalName() + "." + "childPublic");
 expectedFields.add(Parent.class.getCanonicalName() + "." + "parentPublic");
 Collections.sort(fields);
 Collections.sort(expectedFields);
 assertEquals(expectedFields.toString(), fields.toString());
}

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

for (final MetaField field : enclosingType.getFields()) {
 if (field.isAnnotationPresent(AutoBound.class)) {
  assertTypeIsDataBinder(field.getType());

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

for (final MetaField field : enclosingType.getFields()) {
 if (field.isAnnotationPresent(AutoBound.class)) {
  assertTypeIsDataBinder(field.getType());

相关文章