Skip to content

Commit

Permalink
Fix improper null/emptiness check.
Browse files Browse the repository at this point in the history
See #3170
  • Loading branch information
mp911de committed Feb 10, 2025
1 parent f493a88 commit 6ab3133
Showing 1 changed file with 25 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -303,12 +303,35 @@ public boolean isQuoted(int index) {
return quotations.isQuoted(index);
}

/**
* @param name
* @return
* @since 4.0
*/
public boolean hasExpression(String name) {
return expressions.get(name) != null;
}

@Nullable
public ValueExpression getParameter(String name) {
return expressions.get(name);
}

/**
* Returns the required {@link ValueExpression} for the given name or throws an {@link IllegalArgumentException} if
* the parameter is not present.
*
* @param name
* @return
* @throws IllegalArgumentException if the parameter is not present.
* @since 4.0
*/
public ValueExpression getRequiredParameter(String name) {

ValueExpression valueExpression = expressions.get(name);
ValueExpression valueExpression = getParameter(name);

if (valueExpression == null) {
throw new IllegalArgumentException("No ValueExpression with name '%s' found in query.".formatted(name));
throw new IllegalArgumentException("No ValueExpression with name '%s' found in query".formatted(name));
}

return valueExpression;
Expand Down

0 comments on commit 6ab3133

Please sign in to comment.