@Override
 public boolean delete(AppModel model) {
   try {
     LOG.d("DB Delete id", model.getId());
     getRealDao().deleteById(model.getId());
   } catch (SQLException e) {
     LOG.e(e);
     return false;
   }
   return true;
 }
 @Override
 public boolean save(AppModel route) {
   try {
     LOG.d("DB Save");
     getRealDao().createOrUpdate(createDb(route));
   } catch (SQLException e) {
     LOG.e(e);
     return false;
   }
   return true;
 }
  public static <T> T toSimpleModel(String json, Type type) {
    Gson gson = createGSON(true);

    LOG.d("Gson to model: ", json, type);
    T fromJson = null;
    try {
      fromJson = gson.fromJson(json, type);
    } catch (Exception e) {
      fromJson = null;
      LOG.e(e);
    }
    return fromJson;
  }
 @Override
 public AppModel getById(int itemId) {
   try {
     LOG.d("get by id", itemId);
     DbModel db = getRealDao().queryForId(itemId);
     if (db != null) {
       return createApp(db);
     }
   } catch (SQLException e) {
     LOG.e(e);
     return null;
   }
   return null;
 }
 public Dao<DbModel, Integer> getRealDao() {
   try {
     return databaseHelper.getDbDao(clazz);
   } catch (SQLException e) {
     LOG.e(e);
     return null;
   }
 }
 public static <T> T toModel(String json, Class<T> clazz) {
   Gson gson = createGSON(true);
   LOG.d("Gson to model: ", json, clazz);
   T fromJson = null;
   try {
     fromJson = gson.fromJson(json, clazz);
   } catch (Exception e) {
     LOG.e(e);
     try {
       fromJson = clazz.newInstance();
     } catch (Exception e1) {
       LOG.e(e);
       new RuntimeException("GsonConverter instance error");
     }
   }
   return fromJson;
 }
 @Override
 public List<AppModel> getAll() {
   try {
     List<DbModel> queryForAll = getRealDao().queryForAll();
     return transform(queryForAll);
   } catch (SQLException e) {
     LOG.e(e);
   }
   return Collections.emptyList();
 }
 public static byte[] compress(Serializable object) {
   try {
     ByteArrayOutputStream out = new ByteArrayOutputStream();
     GZIPOutputStream gz = new GZIPOutputStream(out);
     ObjectOutputStream oos = new ObjectOutputStream(gz);
     oos.writeObject(object);
     oos.flush();
     oos.close();
     out.close();
     return out.toByteArray();
   } catch (IOException e) {
     LOG.e(e);
   }
   return null;
 }
 @SuppressWarnings("unchecked")
 public static <T> T decompress(byte[] bytes, Class<T> clazz) {
   try {
     ByteArrayInputStream input = new ByteArrayInputStream(bytes);
     GZIPInputStream gs = new GZIPInputStream(input);
     ObjectInputStream ois = new ObjectInputStream(gs);
     T result = (T) ois.readObject();
     ois.close();
     input.close();
     return result;
   } catch (Exception e) {
     LOG.e(e);
   }
   return null;
 }
 public static String toJsonNoExclude(Object model, Type type) {
   Gson gson = createGSON(false);
   String json = gson.toJson(model, type);
   LOG.d("Model to gson: ", json, model);
   return json;
 }
 public static String toJson(Object model, Class<?> clazz) {
   Gson gson = createGSON(true);
   String json = gson.toJson(model, clazz);
   LOG.d("Model to gson: ", json, model);
   return json;
 }