@Test public void getContentValues() { TestModel m = new TestModel(); m.setId(1); m.setTitle("tjena"); ContentValues cv = Utils.getContentValues(m); assertFalse(cv.containsKey("id")); assertEquals(cv.getAsString("title"), "tjena"); }
static ContentValues getContentValues(Model model) { final ModelInfo info = ModelInfo.from(model.getClass()); final ContentValues values = new ContentValues(); for (ModelInfo.ColumnField column : info.columns) { if (column.isAutoIncrement || column.isDynamic) { continue; } column.field.setAccessible(true); Object value; try { value = column.field.get(model); } catch (Exception e) { throw new RuntimeException(e); } Sprinkles.sInstance.getTypeSerializer(column.field.getType()).pack(value, values, column.name); } return values; }
Utils { static ContentValues getContentValues(Model model) { final ModelInfo info = ModelInfo.from(model.getClass()); final ContentValues values = new ContentValues(); for (ModelInfo.ColumnField column : info.columns) { if (column.isAutoIncrement || column.isDynamic) { continue; } column.field.setAccessible(true); Object value; try { value = column.field.get(model); } catch (Exception e) { throw new RuntimeException(e); } Sprinkles.sInstance.getTypeSerializer(column.field.getType()).pack(value, values, column.name); } return values; } }
Utils { static ContentValues getContentValues(Model model) { final ModelInfo info = ModelInfo.from(model.getClass()); final ContentValues values = new ContentValues(); for (ModelInfo.ColumnField column : info.columns) { if (column.isAutoIncrement || column.isDynamic) { continue; } column.field.setAccessible(true); Object value; try { value = column.field.get(model); } catch (Exception e) { throw new RuntimeException(e); } Sprinkles.sInstance.getTypeSerializer(column.field.getType()).pack(value, values, column.name); } return values; }  }
Utils { static ContentValues getContentValues(Model model) { final ModelInfo info = ModelInfo.from(model.getClass()); final ContentValues values = new ContentValues(); for (ModelInfo.ColumnField column : info.columns) { if (column.isAutoIncrement || column.isDynamic) { continue; } column.field.setAccessible(true); Object value; try { value = column.field.get(model); } catch (Exception e) { throw new RuntimeException(e); } Sprinkles.sInstance.getTypeSerializer(column.field.getType()).pack(value, values, column.name); } return values; }   }
Utils { static ContentValues getContentValues(Model model) { final ModelInfo info = ModelInfo.from(model.getClass()); final ContentValues values = new ContentValues(); for (ModelInfo.ColumnField column : info.columns) { if (column.isAutoIncrement || column.isDynamic) { continue; } column.field.setAccessible(true); Object value; try { value = column.field.get(model); } catch (Exception e) { throw new RuntimeException(e); } Sprinkles.sInstance.getTypeSerializer(column.field.getType()).pack(value, values, column.name); } return values; }    }