/** * Check if the specified conditions data already exists in the table. * @param modelClass * Which table to check by class. * @param conditions * A filter declaring which data to check. Exactly same use as * {@link Operator#where(String...)}, except null conditions will result in false. * @return Return true if the specified conditions data already exists in the table. * False otherwise. Null conditions will result in false. */ public static <T> boolean isExist(Class<T> modelClass, String... conditions) { return conditions != null && where(conditions).count(modelClass) > 0; }
/** * Basically same as {@link #find(Class, long)} but pending to a new thread for executing. * * @param modelClass * Which table to query and the object type to return. * @param id * Which record to query. * @return A FindExecutor instance. */ public static <T> FindExecutor<T> findAsync(Class<T> modelClass, long id) { return Operator.findAsync(modelClass, id); }
/** * Basically same as {@link #findFirst(Class)} but pending to a new thread for executing. * * @param modelClass * Which table to query and the object type to return. * @return A FindExecutor instance. */ public static <T> FindExecutor<T> findFirstAsync(Class<T> modelClass) { return findFirstAsync(modelClass, false); }
/** * Basically same as {@link #findAll(Class, long...)} but pending to a new thread for executing. * * @param modelClass * Which table to query and the object type to return as a list. * @param ids * Which records to query. Or do not pass it to find all records. * @return A FindMultiExecutor instance. */ public static <T> FindMultiExecutor<T> findAllAsync(Class<T> modelClass, long... ids) { return findAllAsync(modelClass, false, ids); }
/** * Basically same as {@link #average(String, String)} but pending to a new thread for executing. * * @param tableName * Which table to query from. * @param column * The based on column to calculate. * @return A AverageExecutor instance. */ public static AverageExecutor averageAsync(final String tableName, final String column) { return Operator.averageAsync(tableName, column); }
/** * Basically same as {@link #count(String)} but pending to a new thread for executing. * * @param tableName * Which table to query from. * @return A CountExecutor instance. */ public static CountExecutor countAsync(final String tableName) { return Operator.countAsync(tableName); }
/** * Basically same as {@link #findLast(Class, boolean)} but pending to a new thread for executing. * * @param modelClass * Which table to query and the object type to return. * @param isEager * True to load the associated models, false not. * @return A FindExecutor instance. */ public static <T> FindExecutor<T> findLastAsync(final Class<T> modelClass, final boolean isEager) { return Operator.findLastAsync(modelClass, isEager); }
/** * Provide a way to mark all models in collection as deleted. This means these models' save * state is no longer exist anymore. If save them again, they will be treated as inserting new * data instead of updating the exist one. * @param collection * Collection of models which want to mark as deleted and clear their save state. */ public static <T extends LitePalSupport> void markAsDeleted(Collection<T> collection) { Operator.markAsDeleted(collection); }
/** * Get a writable SQLiteDatabase. * * @return A writable SQLiteDatabase instance */ public static SQLiteDatabase getDatabase() { return Operator.getDatabase(); }
/** * Delete the specified database. * @param dbName * Name of database to delete. * @return True if delete success, false otherwise. */ public static boolean deleteDatabase(String dbName) { return Operator.deleteDatabase(dbName); }
/** * Basically same as {@link #delete(Class, long)} but pending to a new thread for executing. * * @param modelClass * Which table to delete from by class. * @param id * Which record to delete. * @return A UpdateOrDeleteExecutor instance. */ public static UpdateOrDeleteExecutor deleteAsync(final Class<?> modelClass, final long id) { return Operator.deleteAsync(modelClass, id); }
/** * Basically same as {@link #saveAll(Collection)} but pending to a new thread for executing. * * @param collection * Holds all models to save. * @return A SaveExecutor instance. */ public static <T extends LitePalSupport> SaveExecutor saveAllAsync(final Collection<T> collection) { return Operator.saveAllAsync(collection); }
/** * Basically same as {@link #find(Class)} but pending to a new thread for executing. * * @param modelClass * Which table to query and the object type to return as a list. * @return A FindMultiExecutor instance. */ public <T> FindMultiExecutor<T> findAsync(final Class<T> modelClass) { return findAsync(modelClass, false); }
/** * Basically same as {@link #findLast(Class)} but pending to a new thread for executing. * * @param modelClass * Which table to query and the object type to return. * @return A FindExecutor instance. */ public <T> FindExecutor<T> findLastAsync(Class<T> modelClass) { return findLastAsync(modelClass, false); }
/** * Switch the using database to default with configuration by litepal.xml. */ public static void useDefault() { Operator.useDefault(); }
/** * Register a listener to listen database create and upgrade events. */ public static void registerDatabaseListener(DatabaseListener listener) { Operator.registerDatabaseListener(listener); }
/** * Basically same as {@link #find(Class, long)} but pending to a new thread for executing. * * @param modelClass * Which table to query and the object type to return. * @param id * Which record to query. * @return A FindExecutor instance. */ public static <T> FindExecutor<T> findAsync(Class<T> modelClass, long id) { return findAsync(modelClass, id, false); }
/** * Basically same as {@link #findFirst(Class)} but pending to a new thread for executing. * * @param modelClass * Which table to query and the object type to return. * @return A FindExecutor instance. */ public static <T> FindExecutor<T> findFirstAsync(Class<T> modelClass) { return Operator.findFirstAsync(modelClass); }
/** * Basically same as {@link #findAll(Class, long...)} but pending to a new thread for executing. * * @param modelClass * Which table to query and the object type to return as a list. * @param ids * Which records to query. Or do not pass it to find all records. * @return A FindMultiExecutor instance. */ public static <T> FindMultiExecutor<T> findAllAsync(Class<T> modelClass, long... ids) { return Operator.findAllAsync(modelClass, ids); }