com.activeandroid.annotation.Table Java Examples
The following examples show how to use
com.activeandroid.annotation.Table.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TableInfo.java From clear-todolist with GNU General Public License v3.0 | 5 votes |
public TableInfo(Class<? extends Model> type) { mType = type; final Table tableAnnotation = type.getAnnotation(Table.class); if (tableAnnotation != null) { mTableName = tableAnnotation.name(); mIdName = tableAnnotation.id(); } else { mTableName = type.getSimpleName(); } // Manually add the id column since it is not declared like the other columns. Field idField = getIdField(type); mColumnNames.put(idField, mIdName); List<Field> fields = new LinkedList<Field>(ReflectionUtils.getDeclaredColumnFields(type)); Collections.reverse(fields); for (Field field : fields) { if (field.isAnnotationPresent(Column.class)) { final Column columnAnnotation = field.getAnnotation(Column.class); String columnName = columnAnnotation.name(); if (TextUtils.isEmpty(columnName)) { columnName = field.getName(); } mColumnNames.put(field, columnName); } } }
Example #2
Source File: TableInfo.java From mobile-android-survey-app with MIT License | 5 votes |
public TableInfo(Class<? extends Model> type) { mType = type; final Table tableAnnotation = type.getAnnotation(Table.class); if (tableAnnotation != null) { mTableName = tableAnnotation.name(); mIdName = tableAnnotation.id(); } else { mTableName = type.getSimpleName(); } // Manually add the id column since it is not declared like the other columns. Field idField = getIdField(type); mColumnNames.put(idField, mIdName); List<Field> fields = new LinkedList<Field>(ReflectionUtils.getDeclaredColumnFields(type)); Collections.reverse(fields); for (Field field : fields) { if (field.isAnnotationPresent(Column.class)) { final Column columnAnnotation = field.getAnnotation(Column.class); String columnName = columnAnnotation.name(); if (TextUtils.isEmpty(columnName)) { columnName = field.getName(); } mColumnNames.put(field, columnName); } } }