本文整理汇总了Java中com.activeandroid.annotation.Table类的典型用法代码示例。如果您正苦于以下问题:Java Table类的具体用法?Java Table怎么用?Java Table使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Table类属于com.activeandroid.annotation包,在下文中一共展示了Table类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: TableInfo
import com.activeandroid.annotation.Table; //导入依赖的package包/类
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);
}
}
}
示例2: getCart
import com.activeandroid.annotation.Table; //导入依赖的package包/类
public synchronized List<Cart> getCart(long id) {
try {
return new Select().from(Cart.class).where(Table.DEFAULT_ID_NAME + " = ?", id).execute();
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
示例3: getAddress
import com.activeandroid.annotation.Table; //导入依赖的package包/类
public synchronized Address getAddress(long id) {
try {
return new Select().from(Address.class).where(Table.DEFAULT_ID_NAME + " = ?", id).executeSingle();
} catch (Exception e) {
e.printStackTrace();
}
return null;
}