Skip to content

Commit

Permalink
Marked async db operations as deprecated. Developers should handle as…
Browse files Browse the repository at this point in the history
…ync operations in their own way.
  • Loading branch information
zcc1234567 committed May 18, 2020
1 parent 850ca1a commit 4eba868
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 299 deletions.
238 changes: 86 additions & 152 deletions core/src/main/java/org/litepal/FluentQuery.java
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
}

/**
Expand Down Expand Up @@ -198,13 +198,11 @@ public <T> List<T> find(Class<T> modelClass) {
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);
}
Expand Down Expand Up @@ -238,15 +236,11 @@ public <T> List<T> find(Class<T> modelClass, boolean isEager) {
}
}

/**
* 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() {
Expand Down Expand Up @@ -290,13 +284,11 @@ public <T> T findFirst(Class<T> modelClass) {
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);
}
Expand Down Expand Up @@ -330,15 +322,11 @@ public <T> T findFirst(Class<T> modelClass, boolean isEager) {
}
}

/**
* 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() {
Expand Down Expand Up @@ -382,13 +370,11 @@ public <T> T findLast(Class<T> modelClass) {
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);
}
Expand Down Expand Up @@ -439,15 +425,11 @@ public <T> T findLast(Class<T> modelClass, boolean isEager) {
}
}

/**
* 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() {
Expand Down Expand Up @@ -492,13 +474,11 @@ public int count(Class<?> modelClass) {
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())));
}
Expand Down Expand Up @@ -528,13 +508,11 @@ public int count(String tableName) {
}
}

/**
* 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() {
Expand Down Expand Up @@ -580,15 +558,11 @@ public double average(Class<?> modelClass, String column) {
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);
}
Expand Down Expand Up @@ -619,15 +593,11 @@ public double average(String tableName, String column) {
}
}

/**
* 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() {
Expand Down Expand Up @@ -676,17 +646,11 @@ public <T> T max(Class<?> modelClass, String columnName, Class<T> columnType) {
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);
}
Expand Down Expand Up @@ -720,17 +684,11 @@ public <T> T max(String tableName, String columnName, Class<T> columnType) {
}
}

/**
* 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() {
Expand Down Expand Up @@ -779,17 +737,11 @@ public <T> T min(Class<?> modelClass, String columnName, Class<T> columnType) {
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);
}
Expand Down Expand Up @@ -823,17 +775,11 @@ public <T> T min(String tableName, String columnName, Class<T> columnType) {
}
}

/**
* 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() {
Expand Down Expand Up @@ -882,17 +828,11 @@ public <T> T sum(Class<?> modelClass, String columnName, Class<T> columnType) {
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);
}
Expand Down Expand Up @@ -926,17 +866,11 @@ public <T> T sum(String tableName, String columnName, Class<T> columnType) {
}
}

/**
* 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() {
Expand Down
Loading

0 comments on commit 4eba868

Please sign in to comment.