You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@grails.apache.org by bo...@apache.org on 2026/08/15 21:12:43 UTC
(grails-core) 06/14: Fix remaining IntelliJ warnings on DynamicFinder
This is an automated email from the ASF dual-hosted git repository.
borinquenkid pushed a commit to branch test/document-datamapping-core-finders
in repository https://gitbox.apache.org/repos/asf/grails-core.git
commit 71cdca8d119f3513c7d04a1890e871725af41519
Author: Walter Duque de Estrada <wb...@mac.com>
AuthorDate: Sat Aug 15 14:58:33 2026 -0500
Fix remaining IntelliJ warnings on DynamicFinder
- getInitializedExpression's return value is now unused at both call
sites (the last commit dropped the self-reassignments) - change it
to void and drop the stale "@return"/removed-IsNull-path Javadoc
that no longer matched the commented-out code.
- Both populateArgumentsForCriteria overloads wrapped their sort-object
instanceof chain in a redundant "if (sortObject != null)" guard -
instanceof already returns false for null, so the wrapper is
eliminable without changing behavior.
Co-Authored-By: Claude Sonnet 5 <no...@anthropic.com>
---
.../datastore/gorm/finders/DynamicFinder.java | 48 +++++++++-------------
1 file changed, 20 insertions(+), 28 deletions(-)
diff --git a/grails-datamapping-core/src/main/groovy/org/grails/datastore/gorm/finders/DynamicFinder.java b/grails-datamapping-core/src/main/groovy/org/grails/datastore/gorm/finders/DynamicFinder.java
index c5fd28e2e8..1cd8dfac6d 100644
--- a/grails-datamapping-core/src/main/groovy/org/grails/datastore/gorm/finders/DynamicFinder.java
+++ b/grails-datamapping-core/src/main/groovy/org/grails/datastore/gorm/finders/DynamicFinder.java
@@ -395,25 +395,23 @@ public class DynamicFinder implements FinderGrammar {
Object sortObject = argMap.get(ARGUMENT_SORT);
boolean ignoreCase = !argMap.containsKey(ARGUMENT_IGNORE_CASE) || ClassUtils.getBooleanFromMap(ARGUMENT_IGNORE_CASE, argMap);
- if (sortObject != null) {
- if (sortObject instanceof CharSequence) {
- final String sort = sortObject.toString();
+ if (sortObject instanceof CharSequence) {
+ final String sort = sortObject.toString();
+ final Query.Order order = ORDER_DESC.equalsIgnoreCase(orderParam) ? Query.Order.desc(sort) : Query.Order.asc(sort);
+ if (ignoreCase) {
+ order.ignoreCase();
+ }
+ query.order(order);
+ }
+ else if (sortObject instanceof Map sortMap) {
+ for (Object key : sortMap.keySet()) {
+ String sort = key.toString();
final Query.Order order = ORDER_DESC.equalsIgnoreCase(orderParam) ? Query.Order.desc(sort) : Query.Order.asc(sort);
if (ignoreCase) {
order.ignoreCase();
}
query.order(order);
}
- else if (sortObject instanceof Map sortMap) {
- for (Object key : sortMap.keySet()) {
- String sort = key.toString();
- final Query.Order order = ORDER_DESC.equalsIgnoreCase(orderParam) ? Query.Order.desc(sort) : Query.Order.asc(sort);
- if (ignoreCase) {
- order.ignoreCase();
- }
- query.order(order);
- }
- }
}
if (query instanceof QueryArgumentsAware) {
@@ -463,15 +461,13 @@ public class DynamicFinder implements FinderGrammar {
Object sortObject = argMap.get(ARGUMENT_SORT);
boolean ignoreCase = !argMap.containsKey(ARGUMENT_IGNORE_CASE) || ClassUtils.getBooleanFromMap(ARGUMENT_IGNORE_CASE, argMap);
- if (sortObject != null) {
- if (sortObject instanceof CharSequence) {
- final String sort = sortObject.toString();
- final String order = ORDER_DESC.equalsIgnoreCase(orderParam) ? ORDER_DESC : ORDER_ASC;
- addSimpleSort(query, sort, order, ignoreCase);
- }
- else if (sortObject instanceof Map sortMap) {
- applySortForMap(query, sortMap, ignoreCase);
- }
+ if (sortObject instanceof CharSequence) {
+ final String sort = sortObject.toString();
+ final String order = ORDER_DESC.equalsIgnoreCase(orderParam) ? ORDER_DESC : ORDER_ASC;
+ addSimpleSort(query, sort, order, ignoreCase);
+ }
+ else if (sortObject instanceof Map sortMap) {
+ applySortForMap(query, sortMap, ignoreCase);
}
if (query instanceof QueryArgumentsAware) {
@@ -743,21 +739,17 @@ public class DynamicFinder implements FinderGrammar {
}
/**
- * Initializes the arguments of the specified expression with the specified arguments. If the
- * expression is an Equal expression and the argument is null then a new expression is created
- * and returned of type IsNull.
+ * Initializes the arguments of the specified expression with the specified arguments.
*
* @param expression expression to initialize
* @param arguments arguments to the expression
- * @return the initialized expression
*/
- private MethodExpression getInitializedExpression(MethodExpression expression, Object[] arguments) {
+ private void getInitializedExpression(MethodExpression expression, Object[] arguments) {
// if (expression instanceof Equal && arguments.length == 1 && arguments[0] == null) { // logic moved directly to Equal.createCriterion
// expression = new IsNull(expression.propertyName);
// } else {
expression.setArguments(arguments);
// }
- return expression;
}
@Override