Skip to content

Commit f21a5d7

Browse files
committed
modernize some code in o.h.query.sqm.produce.function
1 parent 52ff3b6 commit f21a5d7

14 files changed

+166
-220
lines changed

hibernate-core/src/main/java/org/hibernate/dialect/function/GenerateSeriesArgumentTypeResolver.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
/**
2020
* A {@link ArgumentsValidator} that validates the array type is compatible with the element type.
2121
*/
22-
public class GenerateSeriesArgumentTypeResolver extends AbstractFunctionArgumentTypeResolver {
22+
public class GenerateSeriesArgumentTypeResolver implements AbstractFunctionArgumentTypeResolver {
2323

2424
private final BasicType<Duration> durationType;
2525

hibernate-core/src/main/java/org/hibernate/dialect/function/array/AbstractArrayFillFunction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public String getArgumentListSignature() {
3939
return "(OBJECT element, INTEGER elementCount)";
4040
}
4141

42-
private static class ArrayFillArgumentsValidator extends AbstractFunctionArgumentTypeResolver {
42+
private static class ArrayFillArgumentsValidator implements AbstractFunctionArgumentTypeResolver {
4343

4444
public static final FunctionArgumentTypeResolver INSTANCE = new ArrayFillArgumentsValidator();
4545

hibernate-core/src/main/java/org/hibernate/dialect/function/array/ArrayAndElementArgumentTypeResolver.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
* A {@link FunctionArgumentTypeResolver} that resolves the array argument type based on the element argument type
2222
* or the element argument type based on the array argument type.
2323
*/
24-
public class ArrayAndElementArgumentTypeResolver extends AbstractFunctionArgumentTypeResolver {
24+
public class ArrayAndElementArgumentTypeResolver implements AbstractFunctionArgumentTypeResolver {
2525

2626
public static final FunctionArgumentTypeResolver DEFAULT_INSTANCE = new ArrayAndElementArgumentTypeResolver( 0, 1 );
2727

hibernate-core/src/main/java/org/hibernate/dialect/function/array/ArrayContainsArgumentTypeResolver.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
/**
2020
* A {@link FunctionArgumentTypeResolver} that resolves the argument types for the {@code array_contains} function.
2121
*/
22-
public class ArrayContainsArgumentTypeResolver extends AbstractFunctionArgumentTypeResolver {
22+
public class ArrayContainsArgumentTypeResolver implements AbstractFunctionArgumentTypeResolver {
2323

2424
public static final FunctionArgumentTypeResolver INSTANCE = new ArrayContainsArgumentTypeResolver();
2525

hibernate-core/src/main/java/org/hibernate/dialect/function/array/ArrayIncludesArgumentTypeResolver.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
/**
1818
* A {@link FunctionArgumentTypeResolver} that resolves the argument types for the {@code array_includes} function.
1919
*/
20-
public class ArrayIncludesArgumentTypeResolver extends AbstractFunctionArgumentTypeResolver {
20+
public class ArrayIncludesArgumentTypeResolver implements AbstractFunctionArgumentTypeResolver {
2121

2222
public static final FunctionArgumentTypeResolver INSTANCE = new ArrayIncludesArgumentTypeResolver();
2323

hibernate-core/src/main/java/org/hibernate/query/sqm/produce/function/ArgumentTypesValidator.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public void validate(
7575
BindingContext bindingContext) {
7676
delegate.validate( arguments, functionName, bindingContext );
7777
int count = 0;
78-
for (SqmTypedNode<?> argument : arguments) {
78+
for ( var argument : arguments ) {
7979
// JdbcTypeIndicators indicators = typeConfiguration.getCurrentBaseSqlTypeIndicators();
8080
final SqmExpressible<?> nodeType = argument.getNodeType();
8181
final FunctionParameterType type = count < types.length ? types[count++] : types[types.length - 1];
@@ -182,7 +182,7 @@ public void validateSqlTypes(List<? extends SqlAstNode> arguments, String functi
182182
for ( SqlAstNode argument : arguments ) {
183183
if ( argument instanceof Expression expression ) {
184184
final JdbcMappingContainer expressionType = expression.getExpressionType();
185-
if (expressionType != null) {
185+
if ( expressionType != null ) {
186186
if ( isUnknownExpressionType( expressionType ) ) {
187187
count += expressionType.getJdbcTypeCount();
188188
}
@@ -199,8 +199,8 @@ public void validateSqlTypes(List<? extends SqlAstNode> arguments, String functi
199199
*/
200200
public static boolean isUnknownExpressionType(JdbcMappingContainer expressionType) {
201201
return expressionType instanceof JavaObjectType
202-
|| expressionType instanceof BasicType
203-
&& isUnknown( ((BasicType<?>) expressionType).getJavaTypeDescriptor() );
202+
|| expressionType instanceof BasicType<?> basicType
203+
&& isUnknown( basicType.getJavaTypeDescriptor() );
204204
}
205205

206206
private int validateArgument(int paramNumber, JdbcMappingContainer expressionType, String functionName) {

hibernate-core/src/main/java/org/hibernate/query/sqm/produce/function/FunctionArgumentTypeResolver.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public interface FunctionArgumentTypeResolver {
3232
* @return The resolved type.
3333
* @deprecated Use {@link #resolveFunctionArgumentType(List, int, SqmToSqlAstConverter)} instead
3434
*/
35-
@Deprecated(forRemoval = true)
35+
@Deprecated(forRemoval = true, since = "7.0")
3636
@Nullable MappingModelExpressible<?> resolveFunctionArgumentType(
3737
SqmFunction<?> function,
3838
int argumentIndex,

hibernate-core/src/main/java/org/hibernate/query/sqm/produce/function/StandardArgumentsValidators.java

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public void validate(
9191

9292
@Override
9393
public String getSignature() {
94-
StringBuilder sig = new StringBuilder("(");
94+
final StringBuilder sig = new StringBuilder("(");
9595
for (int i=0; i<minNumOfArgs; i++) {
9696
if (i!=0) {
9797
sig.append(", ");
@@ -128,7 +128,7 @@ public void validate(
128128

129129
@Override
130130
public String getSignature() {
131-
StringBuilder sig = new StringBuilder("(");
131+
final StringBuilder sig = new StringBuilder("(");
132132
for (int i=0; i<number; i++) {
133133
if (i!=0) {
134134
sig.append(", ");
@@ -167,7 +167,7 @@ public void validate(
167167

168168
@Override
169169
public String getSignature() {
170-
StringBuilder sig = new StringBuilder("([");
170+
final StringBuilder sig = new StringBuilder("([");
171171
for (int i=0; i<maxNumOfArgs; i++) {
172172
if (i!=0) {
173173
sig.append(", ");
@@ -187,7 +187,7 @@ public void validate(
187187
List<? extends SqmTypedNode<?>> arguments,
188188
String functionName,
189189
BindingContext bindingContext) {
190-
if (arguments.size() < minNumOfArgs || arguments.size() > maxNumOfArgs) {
190+
if ( arguments.size() < minNumOfArgs || arguments.size() > maxNumOfArgs ) {
191191
throw new FunctionArgumentException(
192192
String.format(
193193
Locale.ROOT,
@@ -203,7 +203,7 @@ public void validate(
203203

204204
@Override
205205
public String getSignature() {
206-
StringBuilder sig = new StringBuilder("(");
206+
final StringBuilder sig = new StringBuilder("(");
207207
for (int i=0; i<maxNumOfArgs; i++) {
208208
if (i==minNumOfArgs) {
209209
sig.append("[");
@@ -226,8 +226,8 @@ public void validate(
226226
List<? extends SqmTypedNode<?>> arguments,
227227
String functionName,
228228
BindingContext bindingContext) {
229-
for ( SqmTypedNode<?> argument : arguments ) {
230-
Class<?> argType = argument.getNodeJavaType().getJavaTypeClass();
229+
for ( var argument : arguments ) {
230+
var argType = argument.getNodeJavaType().getJavaTypeClass();
231231
if ( !javaType.isAssignableFrom( argType ) ) {
232232
throw new FunctionArgumentException(
233233
String.format(
@@ -255,11 +255,8 @@ public void validate(
255255
List<? extends SqmTypedNode<?>> arguments,
256256
String functionName,
257257
BindingContext bindingContext) {
258-
validators.forEach( individualValidator -> individualValidator.validate(
259-
arguments,
260-
functionName,
261-
bindingContext
262-
) );
258+
validators.forEach( individualValidator ->
259+
individualValidator.validate( arguments, functionName, bindingContext ) );
263260
}
264261
};
265262
}

0 commit comments

Comments
 (0)