From 921ee9f8a1bb27bac7f03f522858b00620042b30 Mon Sep 17 00:00:00 2001 From: rbygrave Date: Fri, 3 Sep 2021 09:46:04 +1200 Subject: [PATCH] #2345 - Rename Database.getExpressionFactory() to expressionFactory with deprecation --- ebean-api/src/main/java/io/ebean/DB.java | 20 ++++- ebean-api/src/main/java/io/ebean/Expr.java | 85 ++++++++++------------ 2 files changed, 58 insertions(+), 47 deletions(-) diff --git a/ebean-api/src/main/java/io/ebean/DB.java b/ebean-api/src/main/java/io/ebean/DB.java index a6a831853..4935b5d9e 100644 --- a/ebean-api/src/main/java/io/ebean/DB.java +++ b/ebean-api/src/main/java/io/ebean/DB.java @@ -126,10 +126,18 @@ public final class DB { * an expression that uses OR like Expression e = Expr.or(..., ...); *

*/ - public static ExpressionFactory getExpressionFactory() { + public static ExpressionFactory expressionFactory() { return getDefault().expressionFactory(); } + /** + * Deprecated migrate to expressionFactory(). + */ + @Deprecated + public static ExpressionFactory getExpressionFactory() { + return expressionFactory(); + } + /** * Return the next identity value for a given bean type. *

@@ -1261,10 +1269,18 @@ public final class DB { * Return the BackgroundExecutor service for asynchronous processing of * queries. */ - public static BackgroundExecutor getBackgroundExecutor() { + public static BackgroundExecutor backgroundExecutor() { return getDefault().backgroundExecutor(); } + /** + * Deprecated migrate to backgroundExecutor(). + */ + @Deprecated + public static BackgroundExecutor getBackgroundExecutor() { + return backgroundExecutor(); + } + /** * Return the JsonContext for reading/writing JSON. */ diff --git a/ebean-api/src/main/java/io/ebean/Expr.java b/ebean-api/src/main/java/io/ebean/Expr.java index 01b8f0c49..1316f9873 100644 --- a/ebean-api/src/main/java/io/ebean/Expr.java +++ b/ebean-api/src/main/java/io/ebean/Expr.java @@ -16,7 +16,7 @@ import java.util.Map; * This provides a convenient way to create expressions for the default * database. *

- * See also {@link DB#getExpressionFactory()} + * See also {@link DB#expressionFactory()} *

*

* Creates standard common expressions for using in a Query Where or Having @@ -34,14 +34,14 @@ public class Expr { * Equal To - property equal to the given value. */ public static Expression eq(String propertyName, Object value) { - return DB.getExpressionFactory().eq(propertyName, value); + return DB.expressionFactory().eq(propertyName, value); } /** * Not Equal To - property not equal to the given value. */ public static Expression ne(String propertyName, Object value) { - return DB.getExpressionFactory().ne(propertyName, value); + return DB.expressionFactory().ne(propertyName, value); } /** @@ -49,7 +49,7 @@ public class Expr { * using a lower() function to make it case insensitive). */ public static Expression ieq(String propertyName, String value) { - return DB.getExpressionFactory().ieq(propertyName, value); + return DB.expressionFactory().ieq(propertyName, value); } /** @@ -59,28 +59,28 @@ public class Expr { *

*/ public static Expression inRange(String propertyName, Object value1, Object value2) { - return DB.getExpressionFactory().inRange(propertyName, value1, value2); + return DB.expressionFactory().inRange(propertyName, value1, value2); } /** * Between - property between the two given values. */ public static Expression between(String propertyName, Object value1, Object value2) { - return DB.getExpressionFactory().between(propertyName, value1, value2); + return DB.expressionFactory().between(propertyName, value1, value2); } /** * Between - value between two given properties. */ public static Expression between(String lowProperty, String highProperty, Object value) { - return DB.getExpressionFactory().betweenProperties(lowProperty, highProperty, value); + return DB.expressionFactory().betweenProperties(lowProperty, highProperty, value); } /** * Greater Than - property greater than the given value. */ public static Expression gt(String propertyName, Object value) { - return DB.getExpressionFactory().gt(propertyName, value); + return DB.expressionFactory().gt(propertyName, value); } /** @@ -88,42 +88,42 @@ public class Expr { * value. */ public static Expression ge(String propertyName, Object value) { - return DB.getExpressionFactory().ge(propertyName, value); + return DB.expressionFactory().ge(propertyName, value); } /** * Less Than - property less than the given value. */ public static Expression lt(String propertyName, Object value) { - return DB.getExpressionFactory().lt(propertyName, value); + return DB.expressionFactory().lt(propertyName, value); } /** * Less Than or Equal to - property less than or equal to the given value. */ public static Expression le(String propertyName, Object value) { - return DB.getExpressionFactory().le(propertyName, value); + return DB.expressionFactory().le(propertyName, value); } /** * Is Null - property is null. */ public static Expression isNull(String propertyName) { - return DB.getExpressionFactory().isNull(propertyName); + return DB.expressionFactory().isNull(propertyName); } /** * Is Not Null - property is not null. */ public static Expression isNotNull(String propertyName) { - return DB.getExpressionFactory().isNotNull(propertyName); + return DB.expressionFactory().isNotNull(propertyName); } /** * Case insensitive {@link #exampleLike(Object)} */ public static ExampleExpression iexampleLike(Object example) { - return DB.getExpressionFactory().iexampleLike(example); + return DB.expressionFactory().iexampleLike(example); } /** @@ -131,14 +131,14 @@ public class Expr { * LikeType.RAW (you need to add you own wildcards % and _). */ public static ExampleExpression exampleLike(Object example) { - return DB.getExpressionFactory().exampleLike(example); + return DB.expressionFactory().exampleLike(example); } /** * Create the query by Example expression specifying more options. */ public static ExampleExpression exampleLike(Object example, boolean caseInsensitive, LikeType likeType) { - return DB.getExpressionFactory().exampleLike(example, caseInsensitive, likeType); + return DB.expressionFactory().exampleLike(example, caseInsensitive, likeType); } /** @@ -146,7 +146,7 @@ public class Expr { * characters % (percentage) and _ (underscore). */ public static Expression like(String propertyName, String value) { - return DB.getExpressionFactory().like(propertyName, value); + return DB.expressionFactory().like(propertyName, value); } /** @@ -155,14 +155,14 @@ public class Expr { * a lower() function to make the expression case insensitive. */ public static Expression ilike(String propertyName, String value) { - return DB.getExpressionFactory().ilike(propertyName, value); + return DB.expressionFactory().ilike(propertyName, value); } /** * Starts With - property like value%. */ public static Expression startsWith(String propertyName, String value) { - return DB.getExpressionFactory().startsWith(propertyName, value); + return DB.expressionFactory().startsWith(propertyName, value); } /** @@ -170,14 +170,14 @@ public class Expr { * lower() function to make the expression case insensitive. */ public static Expression istartsWith(String propertyName, String value) { - return DB.getExpressionFactory().istartsWith(propertyName, value); + return DB.expressionFactory().istartsWith(propertyName, value); } /** * Ends With - property like %value. */ public static Expression endsWith(String propertyName, String value) { - return DB.getExpressionFactory().endsWith(propertyName, value); + return DB.expressionFactory().endsWith(propertyName, value); } /** @@ -185,14 +185,14 @@ public class Expr { * function to make the expression case insensitive. */ public static Expression iendsWith(String propertyName, String value) { - return DB.getExpressionFactory().iendsWith(propertyName, value); + return DB.expressionFactory().iendsWith(propertyName, value); } /** * Contains - property like %value%. */ public static Expression contains(String propertyName, String value) { - return DB.getExpressionFactory().contains(propertyName, value); + return DB.expressionFactory().contains(propertyName, value); } /** @@ -200,42 +200,42 @@ public class Expr { * function to make the expression case insensitive. */ public static Expression icontains(String propertyName, String value) { - return DB.getExpressionFactory().icontains(propertyName, value); + return DB.expressionFactory().icontains(propertyName, value); } /** * For collection properties that are empty (have not existing elements). */ public static Expression isEmpty(String propertyName) { - return DB.getExpressionFactory().isEmpty(propertyName); + return DB.expressionFactory().isEmpty(propertyName); } /** * For collection properties that are not empty (have existing elements). */ public static Expression isNotEmpty(String propertyName) { - return DB.getExpressionFactory().isNotEmpty(propertyName); + return DB.expressionFactory().isNotEmpty(propertyName); } /** * In - property has a value in the array of values. */ public static Expression in(String propertyName, Object[] values) { - return DB.getExpressionFactory().in(propertyName, values); + return DB.expressionFactory().in(propertyName, values); } /** * In - using a subQuery. */ public static Expression in(String propertyName, Query subQuery) { - return DB.getExpressionFactory().in(propertyName, subQuery); + return DB.expressionFactory().in(propertyName, subQuery); } /** * In - property has a value in the collection of values. */ public static Expression in(String propertyName, Collection values) { - return DB.getExpressionFactory().in(propertyName, values); + return DB.expressionFactory().in(propertyName, values); } /** @@ -272,14 +272,14 @@ public class Expr { * } */ public static Expression inOrEmpty(String propertyName, Collection values) { - return DB.getExpressionFactory().inOrEmpty(propertyName, values); + return DB.expressionFactory().inOrEmpty(propertyName, values); } /** * Id Equal to - ID property is equal to the value. */ public static Expression idEq(Object value) { - return DB.getExpressionFactory().idEq(value); + return DB.expressionFactory().idEq(value); } /** @@ -292,7 +292,7 @@ public class Expr { * @param propertyMap a map keyed by property names. */ public static Expression allEq(Map propertyMap) { - return DB.getExpressionFactory().allEq(propertyMap); + return DB.expressionFactory().allEq(propertyMap); } /** @@ -303,7 +303,7 @@ public class Expr { *

*/ public static Expression raw(String raw, Object value) { - return DB.getExpressionFactory().raw(raw, value); + return DB.expressionFactory().raw(raw, value); } /** @@ -314,53 +314,48 @@ public class Expr { *

*/ public static Expression raw(String raw, Object[] values) { - return DB.getExpressionFactory().raw(raw, values); + return DB.expressionFactory().raw(raw, values); } /** * Add raw expression with no parameters. */ public static Expression raw(String raw) { - return DB.getExpressionFactory().raw(raw); + return DB.expressionFactory().raw(raw); } /** * And - join two expressions with a logical and. */ public static Expression and(Expression expOne, Expression expTwo) { - - return DB.getExpressionFactory().and(expOne, expTwo); + return DB.expressionFactory().and(expOne, expTwo); } /** * Or - join two expressions with a logical or. */ public static Expression or(Expression expOne, Expression expTwo) { - - return DB.getExpressionFactory().or(expOne, expTwo); + return DB.expressionFactory().or(expOne, expTwo); } /** * Negate the expression (prefix it with NOT). */ public static Expression not(Expression exp) { - - return DB.getExpressionFactory().not(exp); + return DB.expressionFactory().not(exp); } /** * Return a list of expressions that will be joined by AND's. */ public static Junction conjunction(Query query) { - - return DB.getExpressionFactory().conjunction(query); + return DB.expressionFactory().conjunction(query); } /** * Return a list of expressions that will be joined by OR's. */ public static Junction disjunction(Query query) { - - return DB.getExpressionFactory().disjunction(query); + return DB.expressionFactory().disjunction(query); } }