use of com.lidroid.xutils.db.sqlite.FinderLazyLoader in project xUtils by wyouflf.
the class Finder method setValue2Entity.
@Override
public void setValue2Entity(Object entity, Cursor cursor, int index) {
Object value = null;
Class<?> columnType = columnField.getType();
Object finderValue = TableUtils.getColumnOrId(entity.getClass(), this.valueColumnName).getColumnValue(entity);
if (columnType.equals(FinderLazyLoader.class)) {
value = new FinderLazyLoader(this, finderValue);
} else if (columnType.equals(List.class)) {
try {
value = new FinderLazyLoader(this, finderValue).getAllFromDb();
} catch (DbException e) {
LogUtils.e(e.getMessage(), e);
}
} else {
try {
value = new FinderLazyLoader(this, finderValue).getFirstFromDb();
} catch (DbException e) {
LogUtils.e(e.getMessage(), e);
}
}
if (setMethod != null) {
try {
setMethod.invoke(entity, value);
} catch (Throwable e) {
LogUtils.e(e.getMessage(), e);
}
} else {
try {
this.columnField.setAccessible(true);
this.columnField.set(entity, value);
} catch (Throwable e) {
LogUtils.e(e.getMessage(), e);
}
}
}
Aggregations