use of org.greenrobot.greendao.DaoException in project greenDAO by greenrobot.
the class DaoConfig method reflectProperties.
private static Property[] reflectProperties(Class<? extends AbstractDao<?, ?>> daoClass) throws ClassNotFoundException, IllegalArgumentException, IllegalAccessException {
Class<?> propertiesClass = Class.forName(daoClass.getName() + "$Properties");
Field[] fields = propertiesClass.getDeclaredFields();
ArrayList<Property> propertyList = new ArrayList<Property>();
final int modifierMask = Modifier.STATIC | Modifier.PUBLIC;
for (Field field : fields) {
// There might be other fields introduced by some tools, just ignore them (see issue #28)
if ((field.getModifiers() & modifierMask) == modifierMask) {
Object fieldValue = field.get(null);
if (fieldValue instanceof Property) {
propertyList.add((Property) fieldValue);
}
}
}
Property[] properties = new Property[propertyList.size()];
for (Property property : propertyList) {
if (properties[property.ordinal] != null) {
throw new DaoException("Duplicate property ordinals");
}
properties[property.ordinal] = property;
}
return properties;
}
use of org.greenrobot.greendao.DaoException in project greenDAO by greenrobot.
the class LazyListTest method testUncached.
public void testUncached() {
insert(1);
LazyList<TestEntity> listLazy = dao.queryBuilder().build().listLazyUncached();
assertFalse(listLazy.isEmpty());
assertFalse(listLazy.isClosed());
TestEntity entity1 = listLazy.get(0);
TestEntity entity2 = listLazy.get(0);
assertEquals(entity1.getId(), entity2.getId());
if (identityScopeForDao == null) {
assertNotSame(entity1, entity2);
} else {
assertSame(entity1, entity2);
}
assertFalse(listLazy.isClosed());
try {
listLazy.loadRemaining();
fail("Not empty");
} catch (DaoException expected) {
// Expected, OK
}
listLazy.close();
assertTrue(listLazy.isClosed());
}
Aggregations