|
|
|
@ -194,12 +194,13 @@ public abstract class AbstractModel implements Parcelable, Cloneable {
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public synchronized <TYPE> TYPE getValue(Property<TYPE> property) {
|
|
|
|
public synchronized <TYPE> TYPE getValue(Property<TYPE> property) {
|
|
|
|
Object value;
|
|
|
|
Object value;
|
|
|
|
if(setValues != null && setValues.containsKey(property.getColumnName())) {
|
|
|
|
String columnName = property.getColumnName();
|
|
|
|
value = setValues.get(property.getColumnName());
|
|
|
|
if(setValues != null && setValues.containsKey(columnName)) {
|
|
|
|
} else if(values != null && values.containsKey(property.getColumnName())) {
|
|
|
|
value = setValues.get(columnName);
|
|
|
|
value = values.get(property.getColumnName());
|
|
|
|
} else if(values != null && values.containsKey(columnName)) {
|
|
|
|
} else if(getDefaultValues().containsKey(property.getColumnName())) {
|
|
|
|
value = values.get(columnName);
|
|
|
|
value = getDefaultValues().get(property.getColumnName());
|
|
|
|
} else if(getDefaultValues().containsKey(columnName)) {
|
|
|
|
|
|
|
|
value = getDefaultValues().get(columnName);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
throw new UnsupportedOperationException(
|
|
|
|
throw new UnsupportedOperationException(
|
|
|
|
"Model Error: Did not read property " + property.name); //$NON-NLS-1$
|
|
|
|
"Model Error: Did not read property " + property.name); //$NON-NLS-1$
|
|
|
|
@ -208,10 +209,13 @@ public abstract class AbstractModel implements Parcelable, Cloneable {
|
|
|
|
// resolve properties that were retrieved with a different type than accessed
|
|
|
|
// resolve properties that were retrieved with a different type than accessed
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
if(value instanceof String && property instanceof LongProperty) {
|
|
|
|
if(value instanceof String && property instanceof LongProperty) {
|
|
|
|
|
|
|
|
log.debug("{}={} stored as string instead of long", columnName, value);
|
|
|
|
return (TYPE) Long.valueOf((String) value);
|
|
|
|
return (TYPE) Long.valueOf((String) value);
|
|
|
|
} else if(value instanceof String && property instanceof IntegerProperty) {
|
|
|
|
} else if(value instanceof String && property instanceof IntegerProperty) {
|
|
|
|
|
|
|
|
log.debug("{}={} stored as string instead of int", columnName, value);
|
|
|
|
return (TYPE) Integer.valueOf((String) value);
|
|
|
|
return (TYPE) Integer.valueOf((String) value);
|
|
|
|
} else if(value instanceof Integer && property instanceof LongProperty) {
|
|
|
|
} else if(value instanceof Integer && property instanceof LongProperty) {
|
|
|
|
|
|
|
|
log.debug("{}={} stored as int instead of long", columnName, value);
|
|
|
|
return (TYPE) Long.valueOf(((Number) value).longValue());
|
|
|
|
return (TYPE) Long.valueOf(((Number) value).longValue());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return (TYPE) value;
|
|
|
|
return (TYPE) value;
|
|
|
|
|