本文整理匯總了Java中org.litepal.tablemanager.typechange.OrmChange.object2Relation方法的典型用法代碼示例。如果您正苦於以下問題:Java OrmChange.object2Relation方法的具體用法?Java OrmChange.object2Relation怎麽用?Java OrmChange.object2Relation使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.litepal.tablemanager.typechange.OrmChange
的用法示例。
在下文中一共展示了OrmChange.object2Relation方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getTableModel
import org.litepal.tablemanager.typechange.OrmChange; //導入方法依賴的package包/類
/**
* This method is used to get the table model by the class name passed
* in.The principle to generate table model is that each field in the class
* with private modifier and has a type among int/Integer, long/Long,
* short/Short, float/Float, double/Double, char/Character, boolean/Boolean
* or String, would generate a column with same name as corresponding field.
* If users don't want some of the fields map a column, declare them as
* protected or default.
*
* @param className
* The full name of the class to map in database.
* @return A table model with table name, class name and the map of column
* name and column type.
*/
protected TableModel getTableModel(String className) {
String tableName = DBUtility.getTableNameByClassName(className);
TableModel tableModel = new TableModel();
tableModel.setTableName(tableName);
tableModel.setClassName(className);
List<Field> supportedFields = getSupportedFields(className);
for (Field field : supportedFields) {
String fieldName = field.getName();
Class<?> fieldTypeClass = field.getType();
String fieldType = fieldTypeClass.getName();
String columnName = null;
String columnType = null;
for (OrmChange ormChange : typeChangeRules) {
String[] relations = ormChange.object2Relation(className, fieldName, fieldType);
if (relations != null) {
columnName = relations[0];
columnType = relations[1];
tableModel.addColumn(columnName, columnType);
break;
}
}
}
return tableModel;
}
示例2: getColumnType
import org.litepal.tablemanager.typechange.OrmChange; //導入方法依賴的package包/類
/**
* Get the column type for creating table by field type.
* @param fieldType
* Type of field.
* @return The column type for creating table.
*/
protected String getColumnType(String fieldType) {
String columnType;
for (OrmChange ormChange : typeChangeRules) {
columnType = ormChange.object2Relation(fieldType);
if (columnType != null) {
return columnType;
}
}
return null;
}