Use String.repeat() and pattern matching instanceof
Closes gh-27834
This commit is contained in:
parent
7021eb5bb1
commit
ab240f5d8e
|
@ -61,8 +61,7 @@ public class ArgumentTypePreparedStatementSetter implements PreparedStatementSet
|
||||||
if (this.args != null && this.argTypes != null) {
|
if (this.args != null && this.argTypes != null) {
|
||||||
for (int i = 0; i < this.args.length; i++) {
|
for (int i = 0; i < this.args.length; i++) {
|
||||||
Object arg = this.args[i];
|
Object arg = this.args[i];
|
||||||
if (arg instanceof Collection && this.argTypes[i] != Types.ARRAY) {
|
if (arg instanceof Collection<?> entries && this.argTypes[i] != Types.ARRAY) {
|
||||||
Collection<?> entries = (Collection<?>) arg;
|
|
||||||
for (Object entry : entries) {
|
for (Object entry : entries) {
|
||||||
if (entry instanceof Object[] valueArray) {
|
if (entry instanceof Object[] valueArray) {
|
||||||
for (Object argValue : valueArray) {
|
for (Object argValue : valueArray) {
|
||||||
|
|
|
@ -265,8 +265,7 @@ public class PreparedStatementCreatorFactory {
|
||||||
}
|
}
|
||||||
declaredParameter = declaredParameters.get(i);
|
declaredParameter = declaredParameters.get(i);
|
||||||
}
|
}
|
||||||
if (in instanceof Iterable && declaredParameter.getSqlType() != Types.ARRAY) {
|
if (in instanceof Iterable<?> entries && declaredParameter.getSqlType() != Types.ARRAY) {
|
||||||
Iterable<?> entries = (Iterable<?>) in;
|
|
||||||
for (Object entry : entries) {
|
for (Object entry : entries) {
|
||||||
if (entry instanceof Object[] valueArray) {
|
if (entry instanceof Object[] valueArray) {
|
||||||
for (Object argValue : valueArray) {
|
for (Object argValue : valueArray) {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2018 the original author or authors.
|
* Copyright 2002-2021 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -133,12 +133,7 @@ public abstract class AbstractDataFieldMaxValueIncrementer implements DataFieldM
|
||||||
String s = Long.toString(getNextKey());
|
String s = Long.toString(getNextKey());
|
||||||
int len = s.length();
|
int len = s.length();
|
||||||
if (len < this.paddingLength) {
|
if (len < this.paddingLength) {
|
||||||
StringBuilder sb = new StringBuilder(this.paddingLength);
|
s = "0".repeat(this.paddingLength - len) + s;
|
||||||
for (int i = 0; i < this.paddingLength - len; i++) {
|
|
||||||
sb.append('0');
|
|
||||||
}
|
|
||||||
sb.append(s);
|
|
||||||
s = sb.toString();
|
|
||||||
}
|
}
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue