Remove property flags

pull/618/head
Alex Baker 8 years ago
parent d65eee6bd8
commit c1bf0b3b4f

@ -39,13 +39,6 @@ public abstract class Property<TYPE> extends Field implements Cloneable {
/** The database column name for this property */ /** The database column name for this property */
public final String name; public final String name;
/** Can this field be null? */
public static final int PROP_FLAG_NULLABLE = 1;
/** Is this field a date? */
public static final int PROP_FLAG_DATE = 1 << 1;
private int flags = 0;
/** /**
* Create a property by table and column name. Uses the default property * Create a property by table and column name. Uses the default property
* expression which is derived from default table name * expression which is derived from default table name
@ -54,15 +47,6 @@ public abstract class Property<TYPE> extends Field implements Cloneable {
this(table, columnName, (table == null) ? (columnName) : (table.name() + "." + columnName)); this(table, columnName, (table == null) ? (columnName) : (table.name() + "." + columnName));
} }
/**
* Create a property by table and column name. Uses the default property
* expression which is derived from default table name
*/
Property(Table table, String columnName, int flags) {
this(table, columnName, (table == null) ? (columnName) : (table.name() + "." + columnName));
this.flags = flags;
}
/** /**
* Create a property by table and column name, manually specifying an * Create a property by table and column name, manually specifying an
* expression to use in SQL * expression to use in SQL
@ -176,10 +160,6 @@ public abstract class Property<TYPE> extends Field implements Cloneable {
super(table, name); super(table, name);
} }
public StringProperty(Table table, String name, int flags) {
super(table, name, flags);
}
@Override @Override
public <RETURN, PARAMETER> RETURN accept( public <RETURN, PARAMETER> RETURN accept(
PropertyVisitor<RETURN, PARAMETER> visitor, PARAMETER data) { PropertyVisitor<RETURN, PARAMETER> visitor, PARAMETER data) {
@ -248,10 +228,6 @@ public abstract class Property<TYPE> extends Field implements Cloneable {
super(table, name); super(table, name);
} }
public LongProperty(Table table, String name, int flags) {
super(table, name, flags);
}
@Override @Override
public <RETURN, PARAMETER> RETURN accept( public <RETURN, PARAMETER> RETURN accept(
PropertyVisitor<RETURN, PARAMETER> visitor, PARAMETER data) { PropertyVisitor<RETURN, PARAMETER> visitor, PARAMETER data) {
@ -269,10 +245,6 @@ public abstract class Property<TYPE> extends Field implements Cloneable {
} }
} }
public boolean checkFlag(int flag) {
return (flags & flag) > 0;
}
public String getColumnName() { public String getColumnName() {
if (hasAlias()) { if (hasAlias()) {
return alias; return alias;

@ -121,36 +121,24 @@ public class TodorooCursor extends CursorWrapper {
@Override @Override
public Object visitInteger(Property<Integer> property, TodorooCursor cursor) { public Object visitInteger(Property<Integer> property, TodorooCursor cursor) {
int column = columnIndex(property, cursor); int column = columnIndex(property, cursor);
if(property.checkFlag(Property.PROP_FLAG_NULLABLE) && cursor.isNull(column)) {
return null;
}
return cursor.getInt(column); return cursor.getInt(column);
} }
@Override @Override
public Object visitLong(Property<Long> property, TodorooCursor cursor) { public Object visitLong(Property<Long> property, TodorooCursor cursor) {
int column = columnIndex(property, cursor); int column = columnIndex(property, cursor);
if(property.checkFlag(Property.PROP_FLAG_NULLABLE) && cursor.isNull(column)) {
return null;
}
return cursor.getLong(column); return cursor.getLong(column);
} }
@Override @Override
public Object visitDouble(Property<Double> property, TodorooCursor cursor) { public Object visitDouble(Property<Double> property, TodorooCursor cursor) {
int column = columnIndex(property, cursor); int column = columnIndex(property, cursor);
if (property.checkFlag(Property.PROP_FLAG_NULLABLE) && cursor.isNull(column)) {
return null;
}
return cursor.getDouble(column); return cursor.getDouble(column);
} }
@Override @Override
public Object visitString(Property<String> property, TodorooCursor cursor) { public Object visitString(Property<String> property, TodorooCursor cursor) {
int column = columnIndex(property, cursor); int column = columnIndex(property, cursor);
if(property.checkFlag(Property.PROP_FLAG_NULLABLE) && cursor.isNull(column)) {
return null;
}
return cursor.getString(column); return cursor.getString(column);
} }

@ -70,37 +70,37 @@ public class Task extends AbstractModel {
@ColumnInfo(name = "dueDate") @ColumnInfo(name = "dueDate")
public Long dueDate = 0L; public Long dueDate = 0L;
public static final LongProperty DUE_DATE = new LongProperty( public static final LongProperty DUE_DATE = new LongProperty(
TABLE, "dueDate", Property.PROP_FLAG_DATE); TABLE, "dueDate");
/** Unixtime Task should be hidden until, 0 if not set */ /** Unixtime Task should be hidden until, 0 if not set */
@ColumnInfo(name = "hideUntil") @ColumnInfo(name = "hideUntil")
public Long hideUntil = 0L; public Long hideUntil = 0L;
public static final LongProperty HIDE_UNTIL = new LongProperty( public static final LongProperty HIDE_UNTIL = new LongProperty(
TABLE, "hideUntil", Property.PROP_FLAG_DATE); TABLE, "hideUntil");
/** Unixtime Task was created */ /** Unixtime Task was created */
@ColumnInfo(name = "created") @ColumnInfo(name = "created")
public Long created; public Long created;
public static final LongProperty CREATION_DATE = new LongProperty( public static final LongProperty CREATION_DATE = new LongProperty(
TABLE, "created", Property.PROP_FLAG_DATE); TABLE, "created");
/** Unixtime Task was last touched */ /** Unixtime Task was last touched */
@ColumnInfo(name = "modified") @ColumnInfo(name = "modified")
public Long modified; public Long modified;
public static final LongProperty MODIFICATION_DATE = new LongProperty( public static final LongProperty MODIFICATION_DATE = new LongProperty(
TABLE, "modified", Property.PROP_FLAG_DATE); TABLE, "modified");
/** Unixtime Task was completed. 0 means active */ /** Unixtime Task was completed. 0 means active */
@ColumnInfo(name = "completed") @ColumnInfo(name = "completed")
public Long completed = 0L; public Long completed = 0L;
public static final LongProperty COMPLETION_DATE = new LongProperty( public static final LongProperty COMPLETION_DATE = new LongProperty(
TABLE, "completed", Property.PROP_FLAG_DATE); TABLE, "completed");
/** Unixtime Task was deleted. 0 means not deleted */ /** Unixtime Task was deleted. 0 means not deleted */
@ColumnInfo(name = "deleted") @ColumnInfo(name = "deleted")
public Long deleted = 0L; public Long deleted = 0L;
public static final LongProperty DELETION_DATE = new LongProperty( public static final LongProperty DELETION_DATE = new LongProperty(
TABLE, "deleted", Property.PROP_FLAG_DATE); TABLE, "deleted");
// --- non-core task metadata // --- non-core task metadata
@ -122,7 +122,7 @@ public class Task extends AbstractModel {
@ColumnInfo(name = "timerStart") @ColumnInfo(name = "timerStart")
public Long timerStart = 0L; public Long timerStart = 0L;
public static final LongProperty TIMER_START = new LongProperty( public static final LongProperty TIMER_START = new LongProperty(
TABLE, "timerStart", Property.PROP_FLAG_DATE); TABLE, "timerStart");
/** Flags for when to send reminders */ /** Flags for when to send reminders */
@ColumnInfo(name = "notificationFlags") @ColumnInfo(name = "notificationFlags")
@ -134,19 +134,19 @@ public class Task extends AbstractModel {
@ColumnInfo(name = "notifications") @ColumnInfo(name = "notifications")
public Long notifications = 0L; public Long notifications = 0L;
public static final LongProperty REMINDER_PERIOD = new LongProperty( public static final LongProperty REMINDER_PERIOD = new LongProperty(
TABLE, "notifications", Property.PROP_FLAG_DATE); TABLE, "notifications");
/** Unixtime the last reminder was triggered */ /** Unixtime the last reminder was triggered */
@ColumnInfo(name = "lastNotified") @ColumnInfo(name = "lastNotified")
public Long lastNotified = 0L; public Long lastNotified = 0L;
public static final LongProperty REMINDER_LAST = new LongProperty( public static final LongProperty REMINDER_LAST = new LongProperty(
TABLE, "lastNotified", Property.PROP_FLAG_DATE); TABLE, "lastNotified");
/** Unixtime snooze is set (0 -> no snooze) */ /** Unixtime snooze is set (0 -> no snooze) */
@ColumnInfo(name = "snoozeTime") @ColumnInfo(name = "snoozeTime")
public Long snoozeTime = 0L; public Long snoozeTime = 0L;
public static final LongProperty REMINDER_SNOOZE = new LongProperty( public static final LongProperty REMINDER_SNOOZE = new LongProperty(
TABLE, "snoozeTime", Property.PROP_FLAG_DATE); TABLE, "snoozeTime");
@ColumnInfo(name = "recurrence") @ColumnInfo(name = "recurrence")
public String recurrence = ""; public String recurrence = "";
@ -156,7 +156,7 @@ public class Task extends AbstractModel {
@ColumnInfo(name = "repeatUntil") @ColumnInfo(name = "repeatUntil")
public Long repeatUntil = 0L; public Long repeatUntil = 0L;
public static final LongProperty REPEAT_UNTIL = new LongProperty( public static final LongProperty REPEAT_UNTIL = new LongProperty(
TABLE, "repeatUntil", Property.PROP_FLAG_DATE); TABLE, "repeatUntil");
@ColumnInfo(name = "calendarUri") @ColumnInfo(name = "calendarUri")
public String calendarUri = ""; public String calendarUri = "";
@ -172,7 +172,7 @@ public class Task extends AbstractModel {
@ColumnInfo(name = "remoteId") @ColumnInfo(name = "remoteId")
public String remoteId = NO_UUID; public String remoteId = NO_UUID;
public static final StringProperty UUID = new StringProperty( public static final StringProperty UUID = new StringProperty(
TABLE, "remoteId", Property.PROP_FLAG_NULLABLE); TABLE, "remoteId");
/** List of all properties for this model */ /** List of all properties for this model */
public static final Property<?>[] PROPERTIES = generateProperties(Task.class); public static final Property<?>[] PROPERTIES = generateProperties(Task.class);

Loading…
Cancel
Save