use of org.greenrobot.greendao.Property in project greenDAO by greenrobot.
the class WhereCollector method checkProperty.
void checkProperty(Property property) {
if (dao != null) {
Property[] properties = dao.getProperties();
boolean found = false;
for (Property property2 : properties) {
if (property == property2) {
found = true;
break;
}
}
if (!found) {
throw new DaoException("Property '" + property.name + "' is not part of " + dao);
}
}
}
use of org.greenrobot.greendao.Property in project greenDAO by greenrobot.
the class AbstractDaoTestSinglePk method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
Property[] columns = daoAccess.getProperties();
for (Property column : columns) {
if (column.primaryKey) {
if (pkColumn != null) {
throw new RuntimeException("Test does not work with multiple PK columns");
}
pkColumn = column;
}
}
if (pkColumn == null) {
throw new RuntimeException("Test does not work without a PK column");
}
}
use of org.greenrobot.greendao.Property in project greenDAO by greenrobot.
the class QueryBuilder method orderAscOrDesc.
private void orderAscOrDesc(String ascOrDescWithLeadingSpace, Property... properties) {
for (Property property : properties) {
checkOrderBuilder();
append(orderBuilder, property);
if (String.class.equals(property.type) && stringOrderCollation != null) {
orderBuilder.append(stringOrderCollation);
}
orderBuilder.append(ascOrDescWithLeadingSpace);
}
}
use of org.greenrobot.greendao.Property in project greenDAO by greenrobot.
the class QueryBuilder method join.
/**
* Expands the query to another entity type by using a JOIN. The given sourceProperty is used to match the primary
* key property of the given destinationEntity.
*/
public <J> Join<T, J> join(Property sourceProperty, Class<J> destinationEntityClass) {
AbstractDao<J, ?> destinationDao = (AbstractDao<J, ?>) dao.getSession().getDao(destinationEntityClass);
Property destinationProperty = destinationDao.getPkProperty();
return addJoin(tablePrefix, sourceProperty, destinationDao, destinationProperty);
}
use of org.greenrobot.greendao.Property 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;
}
Aggregations