@Documented
@Retention(value=RUNTIME)
@Target(value=FIELD)
public @interface SQLiteColumn
See SQLiteHouse
for details of how this fits into the overall framework.
Modifier and Type | Fields and Description |
---|---|
static int |
NO_INDEX_DEFINED |
Modifier and Type | Required Element and Description |
---|---|
java.lang.String |
name
Specifies the name of the database table column whose schema definition
is derived from this member field; in instances of the class, this field
will contain the values from that database table column.
|
Modifier and Type | Optional Element and Description |
---|---|
int |
index
Roughly-specifies the column index.
|
boolean |
is_nullable
Specifies whether the database column should be nullable.
|
java.lang.Class<? extends Refractor> |
refractor
Optionally specifies a custom
Refractor implementation to be used
to marshal this column to/from the database. |
int |
since
Specifies the first schema version in which this column was defined.
|
java.lang.String |
sql_default
Specifies the string which would be used in a SQLite
CREATE TABLE statement to define the field's default value. |
public abstract java.lang.String name
public abstract int index
SQLightable.Reflection.ColumnSequencer
public abstract boolean is_nullable
true
, will explicitly allow null values. Setting this attribute
to false
will explicitly forbid null values.public abstract java.lang.String sql_default
CREATE TABLE
statement to define the field's default value.
Field Declaration: Unfortunately it is not possible to introspectively use the default value that is declared for the field in the class itself. However, since we specify the default in this annotation, we also allow the consumer to intentionally define something different from the field's declared default. Whether this freedom is of any interesting use is left as an exercise for the reader.
String Enclosure: If the field decorated by this annotation is
a string type, then SQLiteHouse
will automatically surround the
value with quotes as appropriate. An explicit value of "NULL"
for
this parameter will instruct SQLiteHouse
to define the default as
a literal NULL
instead. Do not try to enclose a text value in
single-quotes.
Validation: The algorithms that process the supplied value make no attempt to validate the value with regards to its correspondence to the field's type, etc. For example, if the annotated field is an integer, and a non-numeric string value is supplied here, then you will eventually see exceptions raised from parts of the code that try to parse or use the value.
Handling Null Default Values:The default value for the
annotation parameter is "NULL"
. If the column is nullable, and
this annotation parameter is not specified or is set to "NULL"
explicitly, then the column will be defined with DEFAULT NULL
.
Otherwise, if the column is not nullable, then this annotation parameter
will effectively be required, as a default value must be set for
non-nullable columns.
public abstract int since
SQLiteHouse
will use this information to determine when and
whether to add the column to the database during onCreate()
or
onUpdate()
.public abstract java.lang.Class<? extends Refractor> refractor
Refractor
implementation to be used
to marshal this column to/from the database. This defaults to the
stand-in NullRefractor
class, which will behave as if "null"
were specified here (but we can't, because annotations don't let you do
that).