Use String.repeat() and pattern matching instanceof

Closes gh-27834
This commit is contained in:
a.yazychyan 2021-12-17 01:27:02 +03:00 committed by Sam Brannen
parent 7021eb5bb1
commit ab240f5d8e
3 changed files with 4 additions and 11 deletions

View File

@ -61,8 +61,7 @@ public class ArgumentTypePreparedStatementSetter implements PreparedStatementSet
if (this.args != null && this.argTypes != null) {
for (int i = 0; i < this.args.length; i++) {
Object arg = this.args[i];
if (arg instanceof Collection && this.argTypes[i] != Types.ARRAY) {
Collection<?> entries = (Collection<?>) arg;
if (arg instanceof Collection<?> entries && this.argTypes[i] != Types.ARRAY) {
for (Object entry : entries) {
if (entry instanceof Object[] valueArray) {
for (Object argValue : valueArray) {

View File

@ -265,8 +265,7 @@ public class PreparedStatementCreatorFactory {
}
declaredParameter = declaredParameters.get(i);
}
if (in instanceof Iterable && declaredParameter.getSqlType() != Types.ARRAY) {
Iterable<?> entries = (Iterable<?>) in;
if (in instanceof Iterable<?> entries && declaredParameter.getSqlType() != Types.ARRAY) {
for (Object entry : entries) {
if (entry instanceof Object[] valueArray) {
for (Object argValue : valueArray) {

View File

@ -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");
* 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());
int len = s.length();
if (len < this.paddingLength) {
StringBuilder sb = new StringBuilder(this.paddingLength);
for (int i = 0; i < this.paddingLength - len; i++) {
sb.append('0');
}
sb.append(s);
s = sb.toString();
s = "0".repeat(this.paddingLength - len) + s;
}
return s;
}