本文整理汇总了Java中de.jodamob.reflect.SuperReflect类的典型用法代码示例。如果您正苦于以下问题:Java SuperReflect类的具体用法?Java SuperReflect怎么用?Java SuperReflect使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SuperReflect类属于de.jodamob.reflect包,在下文中一共展示了SuperReflect类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toList
import de.jodamob.reflect.SuperReflect; //导入依赖的package包/类
static <T> List<T> toList(PickleTable dataTable, Type itemType, JsonElement testData) {
List<T> result = new ArrayList<T>();
List<String> keys = convertTopCellsToFieldNames(raw(dataTable.getRows().get(0)));
int count = dataTable.getRows().size();
for (int i = 1; i < count; i++) {
List<String> valueRow = raw(dataTable.getRows().get(i));
T item = (T) SuperReflect.on((Class) itemType).create().get();
int j = 0;
for (String cell : valueRow) {
SuperReflect.on(item).set(keys.get(j), cell);
j++;
}
result.add(item);
}
return Collections.unmodifiableList(result);
}
示例2: waitUntilBottomSheetDisplayed
import de.jodamob.reflect.SuperReflect; //导入依赖的package包/类
private void waitUntilBottomSheetDisplayed() {
MaterialActivityChooserActivity activityChooserActivity = ActivityUtils.getCurrentActivity(mActivityRule);
BottomSheetBehavior.BottomSheetCallback originalBottomSheetCallback = SuperReflect.on(activityChooserActivity).get("mBottomSheetCallback");
if (!(originalBottomSheetCallback instanceof IdlingResourceBottomSheetCallback)) {
final BottomSheetBehavior bottomSheetBehavior = SuperReflect.on(activityChooserActivity)
.get("mBottomSheetBehavior");
/* The bottom sheet gets opened with a delay (using Handler#postDelayed())
* therefore we need to initially wait for the bottom sheet to get to the 'collapsed' state
*/
await().until(new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
return bottomSheetBehavior.getState() == BottomSheetBehavior.STATE_COLLAPSED;
}
});
mIdlingResourceBottomSheetCallback = new IdlingResourceBottomSheetCallback(originalBottomSheetCallback, mBottomSheetIdlingResource);
bottomSheetBehavior.setBottomSheetCallback(mIdlingResourceBottomSheetCallback);
}
onView(withId(R.id.mac_bottom_sheet)).check(matches(isDisplayed()));
}
示例3: bindForTests
import de.jodamob.reflect.SuperReflect; //导入依赖的package包/类
private void bindForTests(Object instanceWithViews) {
SuperReflect reflector = SuperReflect.on(instanceWithViews);
Class<?> instanceWithViewsClass = instanceWithViews.getClass();
do {
bindAllViews(reflector, instanceWithViewsClass);
instanceWithViewsClass = instanceWithViewsClass.getSuperclass();
} while (!instanceWithViewsClass.isAssignableFrom(Object.class));
}
示例4: bindAllViews
import de.jodamob.reflect.SuperReflect; //导入依赖的package包/类
private void bindAllViews(SuperReflect reflector, Class<?> instanceWithViewsClass) {
Field[] fields = instanceWithViewsClass.getDeclaredFields();
for (Field field : fields) {
if (isView(field)) {
tryToMockView(reflector, field);
}
}
}
示例5: tryToSet
import de.jodamob.reflect.SuperReflect; //导入依赖的package包/类
private void tryToSet(SuperReflect reflector, Field field, Object mock) {
try {
reflector.setIfNull(field.getName(), mock);
} catch (Exception e) {
e.printStackTrace();
}
}
示例6: tryToMockView
import de.jodamob.reflect.SuperReflect; //导入依赖的package包/类
private void tryToMockView(SuperReflect reflector, Field field) {
tryToSet(reflector, field, getMockFor(field.getType()));
}