@Test public void testSave() { TestModel model = new TestModel(); testModelModelAdapter.save(model); assertEquals(1, getCount()); }
@NonNull public Long save(@NonNull ModelClass model) { Long id = getModelId(model); if (isModelExists(id)) { update(model, id); } else { id = insert(model, id); } ModelChangeNotifier.get().notifyModelChanged(model, ChangeAction.SAVE); return id; }
ModelAdapter { @NonNull public Long save(@NonNull ModelClass model) { Long id = getModelId(model); if (isModelExists(id)) { update(model, id); } else { id = insert(model, id); } ModelChangeNotifier.get().notifyModelChanged(model, ChangeAction.SAVE); return id; } }
ModelAdapter { @NonNull public Long save(@NonNull ModelClass model) { Long id = getModelId(model); if (isModelExists(id)) { update(model, id); } else { id = insert(model, id); } ModelChangeNotifier.get().notifyModelChanged(model, ChangeAction.SAVE); return id; } ModelAdapter(@NonNull TableInfo tableInfo); }
ModelAdapter { @NonNull public Long save(@NonNull ModelClass model) { Long id = getModelId(model); if (isModelExists(id)) { update(model, id); } else { id = insert(model, id); } ModelChangeNotifier.get().notifyModelChanged(model, ChangeAction.SAVE); return id; } ModelAdapter(@NonNull TableInfo tableInfo); @NonNull TableInfo getTableInfo(); @NonNull ModelCache<ModelClass> getModelCache(); @Nullable ModelClass load(@NonNull Class<ModelClass> type, long id); @NonNull Long save(@NonNull ModelClass model); void delete(@NonNull ModelClass model); void loadFromCursor(@NonNull ModelClass model, @NonNull Cursor cursor); @Nullable Long getModelId(@NonNull ModelClass model); }
ModelAdapter { @NonNull public Long save(@NonNull ModelClass model) { Long id = getModelId(model); if (isModelExists(id)) { update(model, id); } else { id = insert(model, id); } ModelChangeNotifier.get().notifyModelChanged(model, ChangeAction.SAVE); return id; } ModelAdapter(@NonNull TableInfo tableInfo); @NonNull TableInfo getTableInfo(); @NonNull ModelCache<ModelClass> getModelCache(); @Nullable ModelClass load(@NonNull Class<ModelClass> type, long id); @NonNull Long save(@NonNull ModelClass model); void delete(@NonNull ModelClass model); void loadFromCursor(@NonNull ModelClass model, @NonNull Cursor cursor); @Nullable Long getModelId(@NonNull ModelClass model); static final int INSERT_FAILED; }