Remove property flags

pull/618/head
Alex Baker 6 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 */
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
* 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));
}
/**
* 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
* expression to use in SQL
@ -176,10 +160,6 @@ public abstract class Property<TYPE> extends Field implements Cloneable {
super(table, name);
}
public StringProperty(Table table, String name, int flags) {
super(table, name, flags);
}
@Override
public <RETURN, PARAMETER> RETURN accept(
PropertyVisitor<RETURN, PARAMETER> visitor, PARAMETER data) {
@ -248,10 +228,6 @@ public abstract class Property<TYPE> extends Field implements Cloneable {
super(table, name);
}
public LongProperty(Table table, String name, int flags) {
super(table, name, flags);
}
@Override
public <RETURN, PARAMETER> RETURN accept(
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() {
if (hasAlias()) {
return alias;

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

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

Loading…
Cancel
Save