/** * Calculates the maximum value on a given column. The value is returned * with the same data type of the column. * * <pre> * LitePal.max(Person.class, "age", int.class); * </pre> * * You can also specify a where clause when calculating. * * <pre> * LitePal.where("age > ?", "15").max(Person.class, "age", Integer.TYPE); * </pre> * * @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 The maximum value on a given column. */ public static <T> T max(Class<?> modelClass, String columnName, Class<T> columnType) { return Operator.max(modelClass, columnName, columnType); }
/** * Calculates the maximum value on a given column. The value is returned * with the same data type of the column. * * <pre> * LitePal.max("person", "age", int.class); * </pre> * * You can also specify a where clause when calculating. * * <pre> * LitePal.where("age > ?", "15").max("person", "age", Integer.TYPE); * </pre> * * @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 The maximum value on a given column. */ public static <T> T max(String tableName, String columnName, Class<T> columnType) { return Operator.max(tableName, columnName, columnType); }
@Override public void run() { synchronized (LitePalSupport.class) { final T t = max(tableName, columnName, columnType); if (executor.getListener() != null) { Operator.getHandler().post(new Runnable() { @Override public void run() { executor.getListener().onFinish(t); } }); } } } };
/** * Calculates the maximum value on a given column. The value is returned * with the same data type of the column. * * <pre> * LitePal.max(Person.class, "age", int.class); * </pre> * * You can also specify a where clause when calculating. * * <pre> * LitePal.where("age > ?", "15").max(Person.class, "age", Integer.TYPE); * </pre> * * @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 The maximum value on a given column. */ public static <T> T max(Class<?> modelClass, String columnName, Class<T> columnType) { return max(BaseUtility.changeCase(DBUtility.getTableNameByClassName(modelClass.getName())), columnName, columnType); }