本文整理匯總了Java中com.openpojo.reflection.PojoField類的典型用法代碼示例。如果您正苦於以下問題:Java PojoField類的具體用法?Java PojoField怎麽用?Java PojoField使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
PojoField類屬於com.openpojo.reflection包,在下文中一共展示了PojoField類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: include
import com.openpojo.reflection.PojoField; //導入依賴的package包/類
@Override
public boolean include(PojoClass pojoClass) {
List<PojoField> pojoFields = pojoClass.getPojoFields();
List<PojoField> filtered = new ArrayList<>();
for (PojoField pojoField : pojoFields) {
boolean isConstant = pojoField.isStatic() && pojoField.isFinal();
boolean isJaCoCoAddedField = isJaCoCoAddedField(pojoField);
if (!(isConstant || isJaCoCoAddedField)) {
filtered.add(pojoField);
}
}
return !filtered.isEmpty();
}
示例2: isJaCoCoAddedField
import com.openpojo.reflection.PojoField; //導入依賴的package包/類
/**
* JaCoCo coverage calculation tool adds one specific field '$jacocoData' to every tested object. As here we are
* generating test cases based on the field existing in the Class, we need to exclude this additional field.
* <br/>
* Official JaCoCo documentation (take a look at 'My code uses reflection. Why does it fail when I execute it
* with JaCoCo?'): http://www.eclemma.org/jacoco/trunk/doc/faq.html<br/>
* JaCoCo marks this additional field as 'synthetic'. Theoretically, we should be able to exclude it checking
* access modifiers, but PojoField class does not allow to access Field nor exposes any way to check the
* synthetic modifier (newer version version of openpojo library expose this possibility so that after upgrading
* we can replace this method with simply 'pojoField.isSynthetic()').
*/
private boolean isJaCoCoAddedField(PojoField pojoField) {
return "$jacocoData".equals(pojoField.getName());
}