String constraints = extras != null ? extras.constraints() : ColumnSpec.DEFAULT_NONE; if (!ColumnSpec.DEFAULT_NONE.equals(constraints)) { toReturn.append(constraints);
/** * @return the default value given by any existing {@link ColumnSpec} definition, or {@link ColumnSpec#DEFAULT_NONE} * if none is set */ protected String getColumnDefault() { return extras != null ? extras.defaultValue() : ColumnSpec.DEFAULT_NONE; }
@TableModelSpec(className = "Tag", tableName = "tags", tableConstraint = "FOREIGN KEY(taskId) references tasks(_id) ON DELETE CASCADE") public class TagSpec { @PrimaryKey @ColumnSpec(name = "_id") long id; @ColumnSpec(constraints = "NOT NULL") String tag; @ColumnSpec(constraints = "NOT NULL") long taskId; }
@TableModelSpec(className = "Task", tableName = "tasks") public class TaskSpec { @PrimaryKey @ColumnSpec(name = "_id") long id; @ColumnSpec(constraints = "NOT NULL") String title; @ColumnSpec(defaultValue = "0") long completionDate; @ColumnSpec(defaultValue = "0") long dueDate; @ColumnSpec(defaultValue = "0") int priority; @ModelMethod public static boolean isCompleted(Task instance) { return instance.getCompletionDate() > 0; } }
@TableModelSpec(className = "TestVirtualModel", tableName = "virtual_models", virtualModule = "fts4") public class TestVirtualModelSpec { @ColumnSpec(name = "test_num", defaultValue = "7") long testNumber; @ColumnSpec(defaultValue = ColumnSpec.DEFAULT_NULL) String title; @ColumnSpec(defaultValue = ColumnSpec.DEFAULT_NULL) String body; }
/** * @return the default value given by any existing {@link ColumnSpec} definition, or {@link ColumnSpec#DEFAULT_NONE} * if none is set */ protected String getColumnDefault() { return extras != null ? extras.defaultValue() : ColumnSpec.DEFAULT_NONE; }
String constraints = extras != null ? extras.constraints() : ColumnSpec.DEFAULT_NONE; if (!ColumnSpec.DEFAULT_NONE.equals(constraints)) { toReturn.append(constraints);
@TableModelSpec(className = "TestMultiColumnKey", tableName = "multiColumnKey", tableConstraint = "PRIMARY KEY(keyCol1, keyCol2, keyCol3)", noRowIdAlias = true) public class TestMultiColumnKeySpec { @ColumnSpec(constraints = "NOT NULL") String keyCol1; @ColumnSpec(constraints = "NOT NULL") String keyCol2; @ColumnSpec(constraints = "NOT NULL") String keyCol3; String otherData; }
@TableModelSpec(className = "TriggerTester", tableName = "trigger_testers") public class TriggerTesterSpec { @PrimaryKey @ColumnSpec(name = "_id") long id; @ColumnSpec(defaultValue = "0") int value1; @ColumnSpec(defaultValue = "0") int value2; String str1; String str2; }
@TableModelSpec(className = "Employee", tableName = "employees") public class EmployeeSpec { @PrimaryKey @ColumnSpec(name = "_id") long id; @ColumnSpec(constraints = "NOT NULL") String name; long managerId; @ColumnSpec(defaultValue = "true") boolean isHappy; }
@TableModelSpec(className = "Thing", tableName = "things") public class ThingSpec { public static final String DEFAULT_FOO = "thing"; public static final int DEFAULT_BAR = 100; public static final boolean DEFAULT_IS_ALIVE = true; @PrimaryKey(autoincrement = false) long id; @ColumnSpec(defaultValue = DEFAULT_FOO) String foo; @ColumnSpec(defaultValue = "100") int bar; long baz; @ColumnSpec(defaultValue = "0.0") double qux; @ColumnSpec(defaultValue = "true") boolean isAlive; byte[] blob; }
@TableModelSpec(className = "TestNonIntegerPrimaryKey", tableName = "testNonIntegerPrimaryKey") public class TestNonIntegerPrimaryKeySpec { @PrimaryKey @ColumnSpec(name = "keyCol", constraints = "NOT NULL") String key; String value; }
public static final int DEPRECATED_CONST = -1; @ColumnSpec(defaultValue = ColumnSpec.DEFAULT_NULL) String firstName; @ColumnSpec(constraints = "UNIQUE COLLATE NOCASE") String lastName; @ColumnSpec(name = "creationDate") long birthday; @ColumnSpec(defaultValue = "true") boolean isHappy; @ColumnSpec(defaultValue = "7") int luckyNumber; @ColumnSpec(name = "dollar123abc") int $123abc; @ColumnSpec(defaultValue = "[]") @JSONColumn List<String> someList;