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); } } }
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); } } }
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); } } }