提交 4eba868f 编写于 作者: G guolindev

Marked async db operations as deprecated. Developers should handle async...

Marked async db operations as deprecated. Developers should handle async operations in their own way.
上级 850ca1a4
......@@ -42,32 +42,32 @@ public class FluentQuery {
/**
* Representing the selected columns in SQL.
*/
public String[] mColumns;
String[] mColumns;
/**
* Representing the where clause in SQL.
*/
public String[] mConditions;
String[] mConditions;
/**
* Representing the order by clause in SQL.
*/
public String mOrderBy;
String mOrderBy;
/**
* Representing the limit clause in SQL.
*/
public String mLimit;
String mLimit;
/**
* Representing the offset in SQL.
*/
public String mOffset;
String mOffset;
/**
* Do not allow to create instance by developers.
*/
public FluentQuery() {
FluentQuery() {
}
/**
......@@ -198,13 +198,11 @@ public class FluentQuery {
return find(modelClass, false);
}
/**
* 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.
*/
/**
* This method is deprecated and will be removed in the future releases.
* Handle async db operation in your own logic instead.
*/
@Deprecated
public <T> FindMultiExecutor<T> findAsync(final Class<T> modelClass) {
return findAsync(modelClass, false);
}
......@@ -238,15 +236,11 @@ public class FluentQuery {
}
}
/**
* Basically same as {@link #find(Class, boolean)} but pending to a new thread for executing.
*
* @param modelClass
* Which table to query and the object type to return as a list.
* @param isEager
* True to load the associated models, false not.
* @return A FindMultiExecutor instance.
*/
/**
* This method is deprecated and will be removed in the future releases.
* Handle async db operation in your own logic instead.
*/
@Deprecated
public <T> FindMultiExecutor<T> findAsync(final Class<T> modelClass, final boolean isEager) {
final FindMultiExecutor<T> executor = new FindMultiExecutor<>();
Runnable runnable = new Runnable() {
......@@ -290,13 +284,11 @@ public class FluentQuery {
return findFirst(modelClass, 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.
*/
/**
* This method is deprecated and will be removed in the future releases.
* Handle async db operation in your own logic instead.
*/
@Deprecated
public <T> FindExecutor<T> findFirstAsync(Class<T> modelClass) {
return findFirstAsync(modelClass, false);
}
......@@ -330,15 +322,11 @@ public class FluentQuery {
}
}
/**
* Basically same as {@link #findFirst(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.
*/
/**
* This method is deprecated and will be removed in the future releases.
* Handle async db operation in your own logic instead.
*/
@Deprecated
public <T> FindExecutor<T> findFirstAsync(final Class<T> modelClass, final boolean isEager) {
final FindExecutor<T> executor = new FindExecutor<>();
Runnable runnable = new Runnable() {
......@@ -382,13 +370,11 @@ public class FluentQuery {
return findLast(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.
*/
/**
* This method is deprecated and will be removed in the future releases.
* Handle async db operation in your own logic instead.
*/
@Deprecated
public <T> FindExecutor<T> findLastAsync(Class<T> modelClass) {
return findLastAsync(modelClass, false);
}
......@@ -439,15 +425,11 @@ public class FluentQuery {
}
}
/**
* 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.
*/
/**
* This method is deprecated and will be removed in the future releases.
* Handle async db operation in your own logic instead.
*/
@Deprecated
public <T> FindExecutor<T> findLastAsync(final Class<T> modelClass, final boolean isEager) {
final FindExecutor<T> executor = new FindExecutor<>();
Runnable runnable = new Runnable() {
......@@ -492,13 +474,11 @@ public class FluentQuery {
return count(BaseUtility.changeCase(modelClass.getSimpleName()));
}
/**
* Basically same as {@link #count(Class)} but pending to a new thread for executing.
*
* @param modelClass
* Which table to query from by class.
* @return A CountExecutor instance.
*/
/**
* This method is deprecated and will be removed in the future releases.
* Handle async db operation in your own logic instead.
*/
@Deprecated
public CountExecutor countAsync(Class<?> modelClass) {
return countAsync(BaseUtility.changeCase(DBUtility.getTableNameByClassName(modelClass.getName())));
}
......@@ -528,13 +508,11 @@ public class FluentQuery {
}
}
/**
* 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.
*/
/**
* This method is deprecated and will be removed in the future releases.
* Handle async db operation in your own logic instead.
*/
@Deprecated
public CountExecutor countAsync(final String tableName) {
final CountExecutor executor = new CountExecutor();
Runnable runnable = new Runnable() {
......@@ -580,15 +558,11 @@ public class FluentQuery {
return average(BaseUtility.changeCase(modelClass.getSimpleName()), column);
}
/**
* Basically same as {@link #average(Class, String)} but pending to a new thread for executing.
*
* @param modelClass
* Which table to query from by class.
* @param column
* The based on column to calculate.
* @return A AverageExecutor instance.
*/
/**
* This method is deprecated and will be removed in the future releases.
* Handle async db operation in your own logic instead.
*/
@Deprecated
public AverageExecutor averageAsync(final Class<?> modelClass, final String column) {
return averageAsync(BaseUtility.changeCase(DBUtility.getTableNameByClassName(modelClass.getName())), column);
}
......@@ -619,15 +593,11 @@ public class FluentQuery {
}
}
/**
* 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.
*/
/**
* This method is deprecated and will be removed in the future releases.
* Handle async db operation in your own logic instead.
*/
@Deprecated
public AverageExecutor averageAsync(final String tableName, final String column) {
final AverageExecutor executor = new AverageExecutor();
Runnable runnable = new Runnable() {
......@@ -676,17 +646,11 @@ public class FluentQuery {
return max(BaseUtility.changeCase(modelClass.getSimpleName()), columnName, columnType);
}
/**
* Basically same as {@link #max(Class, String, Class)} but pending to a new thread for executing.
*
* @param modelClass
* Which table to query from by class.
* @param columnName
* The based on column to calculate.
* @param columnType
* The type of the based on column.
* @return A FindExecutor instance.
*/
/**
* This method is deprecated and will be removed in the future releases.
* Handle async db operation in your own logic instead.
*/
@Deprecated
public <T> FindExecutor<T> maxAsync(final Class<?> modelClass, final String columnName, final Class<T> columnType) {
return maxAsync(BaseUtility.changeCase(DBUtility.getTableNameByClassName(modelClass.getName())), columnName, columnType);
}
......@@ -720,17 +684,11 @@ public class FluentQuery {
}
}
/**
* Basically same as {@link #max(String, String, Class)} but pending to a new thread for executing.
*
* @param tableName
* Which table to query from.
* @param columnName
* The based on column to calculate.
* @param columnType
* The type of the based on column.
* @return A FindExecutor instance.
*/
/**
* This method is deprecated and will be removed in the future releases.
* Handle async db operation in your own logic instead.
*/
@Deprecated
public <T> FindExecutor<T> maxAsync(final String tableName, final String columnName, final Class<T> columnType) {
final FindExecutor<T> executor = new FindExecutor<>();
Runnable runnable = new Runnable() {
......@@ -779,17 +737,11 @@ public class FluentQuery {
return min(BaseUtility.changeCase(modelClass.getSimpleName()), columnName, columnType);
}
/**
* Basically same as {@link #min(Class, String, Class)} but pending to a new thread for executing.
*
* @param modelClass
* Which table to query from by class.
* @param columnName
* The based on column to calculate.
* @param columnType
* The type of the based on column.
* @return A FindExecutor instance.
*/
/**
* This method is deprecated and will be removed in the future releases.
* Handle async db operation in your own logic instead.
*/
@Deprecated
public <T> FindExecutor<T> minAsync(final Class<?> modelClass, final String columnName, final Class<T> columnType) {
return minAsync(BaseUtility.changeCase(DBUtility.getTableNameByClassName(modelClass.getName())), columnName, columnType);
}
......@@ -823,17 +775,11 @@ public class FluentQuery {
}
}
/**
* Basically same as {@link #min(String, String, Class)} but pending to a new thread for executing.
*
* @param tableName
* Which table to query from.
* @param columnName
* The based on column to calculate.
* @param columnType
* The type of the based on column.
* @return A FindExecutor instance.
*/
/**
* This method is deprecated and will be removed in the future releases.
* Handle async db operation in your own logic instead.
*/
@Deprecated
public <T> FindExecutor<T> minAsync(final String tableName, final String columnName, final Class<T> columnType) {
final FindExecutor<T> executor = new FindExecutor<>();
Runnable runnable = new Runnable() {
......@@ -882,17 +828,11 @@ public class FluentQuery {
return sum(BaseUtility.changeCase(modelClass.getSimpleName()), columnName, columnType);
}
/**
* Basically same as {@link #sum(Class, String, Class)} but pending to a new thread for executing.
*
* @param modelClass
* Which table to query from by class.
* @param columnName
* The based on column to calculate.
* @param columnType
* The type of the based on column.
* @return A FindExecutor instance.
*/
/**
* This method is deprecated and will be removed in the future releases.
* Handle async db operation in your own logic instead.
*/
@Deprecated
public <T> FindExecutor<T> sumAsync(final Class<?> modelClass, final String columnName, final Class<T> columnType) {
return sumAsync(BaseUtility.changeCase(DBUtility.getTableNameByClassName(modelClass.getName())), columnName, columnType);
}
......@@ -926,17 +866,11 @@ public class FluentQuery {
}
}
/**
* Basically same as {@link #sum(String, String, Class)} but pending to a new thread for executing.
*
* @param tableName
* Which table to query from.
* @param columnName
* The based on column to calculate.
* @param columnType
* The type of the based on column.
* @return A FindExecutor instance.
*/
/**
* This method is deprecated and will be removed in the future releases.
* Handle async db operation in your own logic instead.
*/
@Deprecated
public <T> FindExecutor<T> sumAsync(final String tableName, final String columnName, final Class<T> columnType) {
final FindExecutor<T> executor = new FindExecutor<>();
Runnable runnable = new Runnable() {
......
......@@ -154,10 +154,10 @@ public class LitePalSupport {
}
/**
* Basically same as {@link #delete()} but pending to a new thread for executing.
*
* @return A UpdateOrDeleteExecutor instance.
* This method is deprecated and will be removed in the future releases.
* Handle async db operation in your own logic instead.
*/
@Deprecated
public UpdateOrDeleteExecutor deleteAsync() {
final UpdateOrDeleteExecutor executor = new UpdateOrDeleteExecutor();
Runnable runnable = new Runnable() {
......@@ -215,12 +215,10 @@ public class LitePalSupport {
}
/**
* Basically same as {@link #update(long)} but pending to a new thread for executing.
*
* @param id
* Which record to update.
* @return A UpdateOrDeleteExecutor instance.
* This method is deprecated and will be removed in the future releases.
* Handle async db operation in your own logic instead.
*/
@Deprecated
public UpdateOrDeleteExecutor updateAsync(final long id) {
final UpdateOrDeleteExecutor executor = new UpdateOrDeleteExecutor();
Runnable runnable = new Runnable() {
......@@ -286,18 +284,10 @@ public class LitePalSupport {
}
/**
* Basically same as {@link #updateAll(String...)} but pending to a new thread for executing.
*
* @param conditions
* A string array representing the WHERE part of an SQL
* statement. First parameter is the WHERE clause to apply when
* updating. The way of specifying place holders is to insert one
* or more question marks in the SQL. The first question mark is
* replaced by the second element of the array, the next question
* mark by the third, and so on. Passing empty string will update
* all rows.
* @return A UpdateOrDeleteExecutor instance.
* This method is deprecated and will be removed in the future releases.
* Handle async db operation in your own logic instead.
*/
@Deprecated
public UpdateOrDeleteExecutor updateAllAsync(final String... conditions) {
final UpdateOrDeleteExecutor executor = new UpdateOrDeleteExecutor();
Runnable runnable = new Runnable() {
......@@ -355,10 +345,10 @@ public class LitePalSupport {
}
/**
* Basically same as {@link #save()} but pending to a new thread for executing.
*
* @return A SaveExecutor instance.
* This method is deprecated and will be removed in the future releases.
* Handle async db operation in your own logic instead.
*/
@Deprecated
public SaveExecutor saveAsync() {
final SaveExecutor executor = new SaveExecutor();
Runnable runnable = new Runnable() {
......@@ -422,18 +412,6 @@ public class LitePalSupport {
}
}
/**
* This method is deprecated and will be removed in the future releases.
* Use {@link #saveOrUpdate(String...)} instead.
*/
@Deprecated
public boolean saveIfNotExist(String... conditions) {
if (!Operator.isExist(getClass(), conditions)) {
return save();
}
return false;
}
/**
* Save the model if the conditions data not exist, or update the matching models if the conditions data exist. <br>
*
......@@ -497,18 +475,10 @@ public class LitePalSupport {
}
/**
* Basically same as {@link #saveOrUpdate(String...)} but pending to a new thread for executing.
*
* @param conditions
* A string array representing the WHERE part of an SQL
* statement. First parameter is the WHERE clause to apply when
* updating. The way of specifying place holders is to insert one
* or more question marks in the SQL. The first question mark is
* replaced by the second element of the array, the next question
* mark by the third, and so on. Passing empty string will update
* all rows.
* @return A SaveExecutor instance.
* This method is deprecated and will be removed in the future releases.
* Handle async db operation in your own logic instead.
*/
@Deprecated
public SaveExecutor saveOrUpdateAsync(final String... conditions) {
final SaveExecutor executor = new SaveExecutor();
Runnable runnable = new Runnable() {
......
......@@ -108,15 +108,6 @@ inline fun <reified T> FluentQuery.findFirstAsync(): FindExecutor<T> = findFirst
*/
inline fun <reified T> FluentQuery.findFirst(isEager: Boolean): T? = findFirst(T::class.java, isEager)
/**
* Basically same as {@link #findFirst(Class, boolean)} but pending to a new thread for executing.
*
* @param isEager
* True to load the associated models, false not.
* @return A FindExecutor instance.
*/
inline fun <reified T> FluentQuery.findFirstAsync(isEager: Boolean): FindExecutor<T> = findFirstAsync(T::class.java, isEager)
/**
* Finds the last record by the cluster parameters. You can use the below
* way to finish a complicated query:
......@@ -131,13 +122,6 @@ inline fun <reified T> FluentQuery.findFirstAsync(isEager: Boolean): FindExecuto
*/
inline fun <reified T> FluentQuery.findLast(): T? = findLast(T::class.java)
/**
* Basically same as {@link #findLast(Class)} but pending to a new thread for executing.
*
* @return A FindExecutor instance.
*/
inline fun <reified T> FluentQuery.findLastAsync(): FindExecutor<T> = findLastAsync(T::class.java)
/**
* It is mostly same as {@link FluentQuery#findLast(Class)} but an isEager
* parameter. If set true the associated models will be loaded as well.
......@@ -151,15 +135,6 @@ inline fun <reified T> FluentQuery.findLastAsync(): FindExecutor<T> = findLastAs
*/
inline fun <reified T> FluentQuery.findLast(isEager: Boolean): T? = findLast(T::class.java, isEager)
/**
* Basically same as {@link #findLast(Class, boolean)} but pending to a new thread for executing.
*
* @param isEager
* True to load the associated models, false not.
* @return A FindExecutor instance.
*/
inline fun <reified T> FluentQuery.findLastAsync(isEager: Boolean): FindExecutor<T> = findLastAsync(T::class.java, isEager)
/**
* Count the records.
*
......@@ -175,13 +150,6 @@ inline fun <reified T> FluentQuery.findLastAsync(isEager: Boolean): FindExecutor
*/
inline fun <reified T> FluentQuery.count() = count(T::class.java)
/**
* Basically same as [LitePal.count] but pending to a new thread for executing.
*
* @return A CountExecutor instance.
*/
inline fun <reified T> FluentQuery.countAsync() = countAsync(T::class.java)
/**
* Calculates the average value on a given column.
*
......@@ -197,15 +165,6 @@ inline fun <reified T> FluentQuery.countAsync() = countAsync(T::class.java)
*/
inline fun <reified T> FluentQuery.average(column: String) = average(T::class.java, column)
/**
* Basically same as [LitePal.average] but pending to a new thread for executing.
*
* @param column
* The based on column to calculate.
* @return A AverageExecutor instance.
*/
inline fun <reified T> FluentQuery.averageAsync(column: String) = averageAsync(T::class.java, column)
/**
* Calculates the maximum value on a given column. The value is returned
* with the same data type of the column.
......@@ -223,15 +182,6 @@ inline fun <reified T> FluentQuery.averageAsync(column: String) = averageAsync(T
*/
inline fun <reified T, reified R> FluentQuery.max(columnName: String): R = max(T::class.java, columnName, R::class.java)
/**
* Basically same as [LitePal.max] but pending to a new thread for executing.
*
* @param columnName
* The based on column to calculate.
* @return A FindExecutor instance.
*/
inline fun <reified T, reified R> FluentQuery.maxAsync(columnName: String) = maxAsync(T::class.java, columnName, R::class.java)
/**
* Calculates the maximum value on a given column. The value is returned
* with the same data type of the column.
......@@ -250,17 +200,6 @@ inline fun <reified T, reified R> FluentQuery.maxAsync(columnName: String) = max
*/
inline fun <reified R> FluentQuery.max(tableName: String, columnName: String): R = max(tableName, columnName, R::class.java)
/**
* Basically same as [LitePal.max] but pending to a new thread for executing.
*
* @param tableName
* Which table to query from.
* @param columnName
* The based on column to calculate.
* @return A FindExecutor instance.
*/
inline fun <reified R> FluentQuery.maxAsync(tableName: String, columnName: String) = maxAsync(tableName, columnName, R::class.java)
/**
* Calculates the minimum value on a given column. The value is returned
* with the same data type of the column.
......@@ -277,15 +216,6 @@ inline fun <reified R> FluentQuery.maxAsync(tableName: String, columnName: Strin
*/
inline fun <reified T, reified R> FluentQuery.min(columnName: String): R = min(T::class.java, columnName, R::class.java)
/**
* Basically same as [LitePal.min] but pending to a new thread for executing.
*
* @param columnName
* The based on column to calculate.
* @return A FindExecutor instance.
*/
inline fun <reified T, reified R> FluentQuery.minAsync(columnName: String) = minAsync(T::class.java, columnName, R::class.java)
/**
* Calculates the minimum value on a given column. The value is returned
* with the same data type of the column.
......@@ -304,17 +234,6 @@ inline fun <reified T, reified R> FluentQuery.minAsync(columnName: String) = min
*/
inline fun <reified R> FluentQuery.min(tableName: String, columnName: String): R = min(tableName, columnName, R::class.java)
/**
* Basically same as [LitePal.min] but pending to a new thread for executing.
*
* @param tableName
* Which table to query from.
* @param columnName
* The based on column to calculate.
* @return A FindExecutor instance.
*/
inline fun <reified R> FluentQuery.minAsync(tableName: String, columnName: String) = minAsync(tableName, columnName, R::class.java)
/**
* Calculates the sum of values on a given column. The value is returned
* with the same data type of the column.
......@@ -331,15 +250,6 @@ inline fun <reified R> FluentQuery.minAsync(tableName: String, columnName: Strin
*/
inline fun <reified T, reified R> FluentQuery.sum(columnName: String): R = sum(T::class.java, columnName, R::class.java)
/**
* Basically same as [LitePal.sum] but pending to a new thread for executing.
*
* @param columnName
* The based on column to calculate.
* @return A FindExecutor instance.
*/
inline fun <reified T, reified R> FluentQuery.sumAsync(columnName: String) = sumAsync(T::class.java, columnName, R::class.java)
/**
* Calculates the sum of values on a given column. The value is returned
* with the same data type of the column.
......@@ -356,15 +266,4 @@ inline fun <reified T, reified R> FluentQuery.sumAsync(columnName: String) = sum
* The based on column to calculate.
* @return The sum value on a given column.
*/
inline fun <reified R> FluentQuery.sum(tableName: String, columnName: String): R = sum(tableName, columnName, R::class.java)
/**
* Basically same as [LitePal.sum] but pending to a new thread for executing.
*
* @param tableName
* Which table to query from.
* @param columnName
* The based on column to calculate.
* @return A FindExecutor instance.
*/
inline fun <reified R> FluentQuery.sumAsync(tableName: String, columnName: String) = sumAsync(tableName, columnName, R::class.java)
\ No newline at end of file
inline fun <reified R> FluentQuery.sum(tableName: String, columnName: String): R = sum(tableName, columnName, R::class.java)
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册