T - the entity typepublic interface EntityConverter<T>
ContentValues and from a Cursor| Modifier and Type | Interface and Description |
|---|---|
static class |
EntityConverter.Column
Holds the column name and type
|
static class |
EntityConverter.ColumnType
The SQLite column type
|
| Modifier and Type | Method and Description |
|---|---|
T |
fromCursor(android.database.Cursor cursor)
Create an entity from the cursor.
|
java.util.List<EntityConverter.Column> |
getColumns()
Get the database column names along with the colum types
|
java.lang.Long |
getId(T instance)
Get the id of an entity
|
java.lang.String |
getTable()
Get the database table for the entity
|
void |
setId(java.lang.Long id,
T instance)
Set the id value on an entity
|
void |
toValues(T object,
android.content.ContentValues values)
Convert an entity to content values
Generally speaking do not add content values for columns that aren't returned from
getColumns() and omit columns of value EntityConverter.ColumnType.JOIN |
T fromCursor(android.database.Cursor cursor)
getColumns(),
but the number of columns might be less if the result does not contain them.
For example, if the converter has 10 columns and the cursor has only 7, the columns 0-6 from getColumns() will be supplied, even
if the original cursor does not contain all of them. This allows a EntityConverter to iterate over the columns without checking for column name.
Note the contract between @{link #getColumns} and this function: getColumns() should always specify the required columns for conversion. Any unlisted columns will be dropped from
the cursor that is supplied here for performance reasons.cursor - the cursorvoid toValues(T object, android.content.ContentValues values)
getColumns() and omit columns of value EntityConverter.ColumnType.JOINobject - the entityvalues - the content values to populatejava.util.List<EntityConverter.Column> getColumns()
EntityConverter.ColumnTypevoid setId(java.lang.Long id,
T instance)
id - the idinstance - the instance to set the id onjava.lang.Long getId(T instance)
instance - the entityjava.lang.String getTable()