1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173
| package com.wangjie.rapidorm.example.database.model;
import android.database.Cursor; import com.wangjie.rapidorm.core.config.ColumnConfig; import com.wangjie.rapidorm.core.config.TableConfig; import java.util.List;
public class Person_RORM extends TableConfig<Person> {
public static final String ID = "id";
public static final String TYPE_ID = "type_id";
public static final String NAME = "name";
public static final String AGE = "age";
public static final String ADDRESS = "address";
public static final String BIRTH = "birth";
public static final String STUDENT = "student";
public static final String IS_SUCCEED = "is_succeed";
public Person_RORM() { super(Person.class); }
@Override protected void parseAllConfigs() { tableName = "Person"; ColumnConfig idColumnConfig = buildColumnConfig("id", false, false, "", false, false, false, true, "INTEGER"); allColumnConfigs.add(idColumnConfig); allFieldColumnConfigMapper.put("id", idColumnConfig); pkColumnConfigs.add(idColumnConfig); ColumnConfig typeIdColumnConfig = buildColumnConfig("type_id", false, false, "", false, false, false, true, "INTEGER"); allColumnConfigs.add(typeIdColumnConfig); allFieldColumnConfigMapper.put("typeId", typeIdColumnConfig); pkColumnConfigs.add(typeIdColumnConfig); ColumnConfig nameColumnConfig = buildColumnConfig("name", false, false, "", false, false, false, false, "TEXT"); allColumnConfigs.add(nameColumnConfig); allFieldColumnConfigMapper.put("name", nameColumnConfig); noPkColumnConfigs.add(nameColumnConfig); ColumnConfig ageColumnConfig = buildColumnConfig("age", false, false, "", false, false, false, false, "INTEGER"); allColumnConfigs.add(ageColumnConfig); allFieldColumnConfigMapper.put("age", ageColumnConfig); noPkColumnConfigs.add(ageColumnConfig); ColumnConfig addressColumnConfig = buildColumnConfig("address", false, false, "", false, false, false, false, "TEXT"); allColumnConfigs.add(addressColumnConfig); allFieldColumnConfigMapper.put("address", addressColumnConfig); noPkColumnConfigs.add(addressColumnConfig); ColumnConfig birthColumnConfig = buildColumnConfig("birth", false, false, "", false, false, false, false, "LONG"); allColumnConfigs.add(birthColumnConfig); allFieldColumnConfigMapper.put("birth", birthColumnConfig); noPkColumnConfigs.add(birthColumnConfig); ColumnConfig studentColumnConfig = buildColumnConfig("student", false, false, "", false, false, false, false, "INTEGER"); allColumnConfigs.add(studentColumnConfig); allFieldColumnConfigMapper.put("student", studentColumnConfig); noPkColumnConfigs.add(studentColumnConfig); ColumnConfig isSucceedColumnConfig = buildColumnConfig("is_succeed", false, false, "", false, false, false, false, "INTEGER"); allColumnConfigs.add(isSucceedColumnConfig); allFieldColumnConfigMapper.put("isSucceed", isSucceedColumnConfig); noPkColumnConfigs.add(isSucceedColumnConfig); }
@Override public void bindInsertArgs(Person model, List<Object> insertArgs) { Integer id = model.id; insertArgs.add(null == id ? null : id ); Integer typeId = model.typeId; insertArgs.add(null == typeId ? null : typeId ); String name = model.name; insertArgs.add(null == name ? null : name ); int age = model.age; insertArgs.add(age); String address = model.address; insertArgs.add(null == address ? null : address ); Long birth = model.birth; insertArgs.add(null == birth ? null : birth ); Boolean student = model.student; insertArgs.add(null == student ? null : student ? 1 : 0); boolean isSucceed = model.isSucceed; insertArgs.add(isSucceed ? 1 : 0); }
@Override public void bindUpdateArgs(Person model, List<Object> updateArgs) { String name = model.name; updateArgs.add(null == name ? null : name); int age = model.age; updateArgs.add(age); String address = model.address; updateArgs.add(null == address ? null : address); Long birth = model.birth; updateArgs.add(null == birth ? null : birth); Boolean student = model.student; updateArgs.add(null == student ? null : student ? 1 : 0); boolean isSucceed = model.isSucceed; updateArgs.add(isSucceed ? 1 : 0); }
@Override public void bindPkArgs(Person model, List<Object> pkArgs) { Integer id = model.id; pkArgs.add(null == id ? null : id); Integer typeId = model.typeId; pkArgs.add(null == typeId ? null : typeId); }
@Override public Person parseFromCursor(Cursor cursor) { Person model = new Person(); int index; index = cursor.getColumnIndex("id"); if(-1 != index) { model.id = cursor.isNull(index) ? null : (cursor.getInt(index)); } index = cursor.getColumnIndex("type_id"); if(-1 != index) { model.typeId = cursor.isNull(index) ? null : (cursor.getInt(index)); } index = cursor.getColumnIndex("name"); if(-1 != index) { model.name = cursor.isNull(index) ? null : (cursor.getString(index)); } index = cursor.getColumnIndex("age"); if(-1 != index) { model.age = cursor.isNull(index) ? null : (cursor.getInt(index)); } index = cursor.getColumnIndex("address"); if(-1 != index) { model.address = cursor.isNull(index) ? null : (cursor.getString(index)); } index = cursor.getColumnIndex("birth"); if(-1 != index) { model.birth = cursor.isNull(index) ? null : (cursor.getLong(index)); } index = cursor.getColumnIndex("student"); if(-1 != index) { model.student = cursor.isNull(index) ? null : (cursor.getInt(index) == 1); } index = cursor.getColumnIndex("is_succeed"); if(-1 != index) { model.isSucceed = cursor.isNull(index) ? null : (cursor.getInt(index) == 1); } return model; } }
|