提交 a2ef6bad 编写于 作者: S Sam Brannen

Use StringBuilder.append(char) where possible

To slightly improve performance, this commit switches to
StringBuilder.append(char) instead of StringBuilder.append(String)
whenever we append a single character to a StringBuilder.

Closes gh-27098
上级 ddbb7c1b
/*
* Copyright 2002-2020 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.
......@@ -625,7 +625,7 @@ public class AspectJAdviceParameterNameDiscoverer implements ParameterNameDiscov
StringBuilder sb = new StringBuilder();
if (bodyStart >= 0 && bodyStart != (currentToken.length() - 1)) {
sb.append(currentToken.substring(bodyStart + 1));
sb.append(" ");
sb.append(' ');
}
numTokensConsumed++;
int currentIndex = startIndex + numTokensConsumed;
......@@ -645,7 +645,7 @@ public class AspectJAdviceParameterNameDiscoverer implements ParameterNameDiscov
toAppend = toAppend.substring(1);
}
sb.append(toAppend);
sb.append(" ");
sb.append(' ');
currentIndex++;
numTokensConsumed++;
}
......
/*
* 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.
......@@ -547,7 +547,7 @@ public class AspectJExpressionPointcut extends AbstractExpressionPointcut
StringBuilder sb = new StringBuilder("AspectJExpressionPointcut: (");
for (int i = 0; i < this.pointcutParameterTypes.length; i++) {
sb.append(this.pointcutParameterTypes[i].getName());
sb.append(" ");
sb.append(' ');
sb.append(this.pointcutParameterNames[i]);
if ((i+1) < this.pointcutParameterTypes.length) {
sb.append(", ");
......
/*
* Copyright 2002-2020 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.
......@@ -255,19 +255,19 @@ public class MethodInvocationProceedingJoinPoint implements ProceedingJoinPoint,
StringBuilder sb = new StringBuilder();
if (includeModifier) {
sb.append(Modifier.toString(getModifiers()));
sb.append(" ");
sb.append(' ');
}
if (includeReturnTypeAndArgs) {
appendType(sb, getReturnType(), useLongReturnAndArgumentTypeName);
sb.append(" ");
sb.append(' ');
}
appendType(sb, getDeclaringType(), useLongTypeName);
sb.append(".");
sb.append('.');
sb.append(getMethod().getName());
sb.append("(");
sb.append('(');
Class<?>[] parametersTypes = getParameterTypes();
appendTypes(sb, parametersTypes, includeReturnTypeAndArgs, useLongReturnAndArgumentTypeName);
sb.append(")");
sb.append(')');
return sb.toString();
}
......@@ -278,7 +278,7 @@ public class MethodInvocationProceedingJoinPoint implements ProceedingJoinPoint,
for (int size = types.length, i = 0; i < size; i++) {
appendType(sb, types[i], useLongReturnAndArgumentTypeName);
if (i < size - 1) {
sb.append(",");
sb.append(',');
}
}
}
......
/*
* Copyright 2002-2017 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.
......@@ -137,7 +137,7 @@ public abstract class AbstractBeanFactoryPointcutAdvisor extends AbstractPointcu
StringBuilder sb = new StringBuilder(getClass().getName());
sb.append(": advice ");
if (this.adviceBeanName != null) {
sb.append("bean '").append(this.adviceBeanName).append("'");
sb.append("bean '").append(this.adviceBeanName).append('\'');
}
else {
sb.append(this.advice);
......
......@@ -191,9 +191,9 @@ public abstract class AbstractBeanFactoryBasedTargetSource implements TargetSour
@Override
public String toString() {
StringBuilder sb = new StringBuilder(getClass().getSimpleName());
sb.append(" for target bean '").append(this.targetBeanName).append("'");
sb.append(" for target bean '").append(this.targetBeanName).append('\'');
if (this.targetClass != null) {
sb.append(" of type [").append(this.targetClass.getName()).append("]");
sb.append(" of type [").append(this.targetClass.getName()).append(']');
}
return sb.toString();
}
......
......@@ -276,14 +276,14 @@ public class AspectJAdviceParameterNameDiscovererTests {
private static String format(String[] names) {
StringBuilder sb = new StringBuilder();
sb.append("(");
sb.append('(');
for (int i = 0; i < names.length; i++) {
sb.append(names[i]);
if ((i + 1) < names.length) {
sb.append(",");
sb.append(',');
}
}
sb.append(")");
sb.append(')');
return sb.toString();
}
......
......@@ -247,14 +247,14 @@ class TypeConverterDelegate {
// Definitely doesn't match: throw IllegalArgumentException/IllegalStateException
StringBuilder msg = new StringBuilder();
msg.append("Cannot convert value of type '").append(ClassUtils.getDescriptiveType(newValue));
msg.append("' to required type '").append(ClassUtils.getQualifiedName(requiredType)).append("'");
msg.append("' to required type '").append(ClassUtils.getQualifiedName(requiredType)).append('\'');
if (propertyName != null) {
msg.append(" for property '").append(propertyName).append("'");
msg.append(" for property '").append(propertyName).append('\'');
}
if (editor != null) {
msg.append(": PropertyEditor [").append(editor.getClass().getName()).append(
"] returned inappropriate value of type '").append(
ClassUtils.getDescriptiveType(convertedValue)).append("'");
ClassUtils.getDescriptiveType(convertedValue)).append('\'');
throw new IllegalArgumentException(msg.toString());
}
else {
......
/*
* Copyright 2002-2020 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.
......@@ -217,13 +217,13 @@ public class RequiredAnnotationBeanPostProcessor implements SmartInstantiationAw
sb.append(" and");
}
else {
sb.append(",");
sb.append(',');
}
}
sb.append(" '").append(propertyName).append("'");
sb.append(" '").append(propertyName).append('\'');
}
sb.append(size == 1 ? " is" : " are");
sb.append(" required for bean '").append(beanName).append("'");
sb.append(" required for bean '").append(beanName).append('\'');
return sb.toString();
}
......
......@@ -1241,7 +1241,7 @@ public abstract class AbstractBeanDefinition extends BeanMetadataAttributeAccess
@Override
public String toString() {
StringBuilder sb = new StringBuilder("class [");
sb.append(getBeanClassName()).append("]");
sb.append(getBeanClassName()).append(']');
sb.append("; scope=").append(this.scope);
sb.append("; abstract=").append(this.abstractFlag);
sb.append("; lazyInit=").append(this.lazyInit);
......
/*
* Copyright 2002-2019 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.
......@@ -138,7 +138,7 @@ abstract class AbstractJCacheOperation<A extends Annotation> implements JCacheOp
@Override
public String toString() {
return getOperationDescription().append("]").toString();
return getOperationDescription().append(']').toString();
}
/**
......@@ -148,7 +148,7 @@ abstract class AbstractJCacheOperation<A extends Annotation> implements JCacheOp
protected StringBuilder getOperationDescription() {
StringBuilder result = new StringBuilder();
result.append(getClass().getSimpleName());
result.append("[");
result.append('[');
result.append(this.methodDetails);
return result;
}
......
/*
* 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.
......@@ -71,9 +71,9 @@ public class CacheEvictOperation extends CacheOperation {
@Override
protected StringBuilder getOperationDescription() {
StringBuilder sb = super.getOperationDescription();
sb.append(",");
sb.append(',');
sb.append(this.cacheWide);
sb.append(",");
sb.append(',');
sb.append(this.beforeInvocation);
return sb;
}
......
/*
* 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.
......@@ -216,13 +216,13 @@ public abstract class CacheOperation implements BasicOperation {
*/
protected StringBuilder getOperationDescription() {
StringBuilder result = new StringBuilder(getClass().getSimpleName());
result.append("[").append(this.name);
result.append('[').append(this.name);
result.append("] caches=").append(this.cacheNames);
result.append(" | key='").append(this.key);
result.append("' | keyGenerator='").append(this.keyGenerator);
result.append("' | cacheManager='").append(this.cacheManager);
result.append("' | cacheResolver='").append(this.cacheResolver);
result.append("' | condition='").append(this.condition).append("'");
result.append("' | condition='").append(this.condition).append('\'');
return result;
}
......
/*
* 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.
......@@ -66,7 +66,7 @@ public class CachePutOperation extends CacheOperation {
StringBuilder sb = super.getOperationDescription();
sb.append(" | unless='");
sb.append(this.unless);
sb.append("'");
sb.append('\'');
return sb;
}
......
/*
* 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.
......@@ -79,10 +79,10 @@ public class CacheableOperation extends CacheOperation {
StringBuilder sb = super.getOperationDescription();
sb.append(" | unless='");
sb.append(this.unless);
sb.append("'");
sb.append('\'');
sb.append(" | sync='");
sb.append(this.sync);
sb.append("'");
sb.append('\'');
return sb;
}
......
......@@ -396,7 +396,7 @@ public class ApplicationListenerMethodAdapter implements GenericApplicationListe
* @param message error message to append the HandlerMethod details to
*/
protected String getDetailedErrorMessage(Object bean, String message) {
StringBuilder sb = new StringBuilder(message).append("\n");
StringBuilder sb = new StringBuilder(message).append('\n');
sb.append("HandlerMethod details: \n");
sb.append("Bean [").append(bean.getClass().getName()).append("]\n");
sb.append("Method [").append(this.method.toGenericString()).append("]\n");
......@@ -426,7 +426,7 @@ public class ApplicationListenerMethodAdapter implements GenericApplicationListe
StringBuilder sb = new StringBuilder(getDetailedErrorMessage(bean, message));
sb.append("Resolved arguments: \n");
for (int i = 0; i < resolvedArgs.length; i++) {
sb.append("[").append(i).append("] ");
sb.append('[').append(i).append("] ");
if (resolvedArgs[i] == null) {
sb.append("[null] \n");
}
......
/*
* Copyright 2002-2020 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.
......@@ -205,12 +205,12 @@ public class LiveBeansView implements LiveBeansViewMBean, ApplicationContextAwar
}
}
result.append("]\n");
result.append("}");
result.append('}');
if (it.hasNext()) {
result.append(",\n");
}
}
result.append("]");
result.append(']');
return result.toString();
}
......
/*
* 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.
......@@ -324,7 +324,7 @@ public class Constants {
for (int i = 0; i < propertyName.length(); i++) {
char c = propertyName.charAt(i);
if (Character.isUpperCase(c)) {
parsedPrefix.append("_");
parsedPrefix.append('_');
parsedPrefix.append(c);
}
else {
......
/*
* Copyright 2002-2019 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.
......@@ -394,9 +394,11 @@ public class AnnotationAttributes extends LinkedHashMap<String, Object> {
sb.append(entry.getKey());
sb.append('=');
sb.append(valueToString(entry.getValue()));
sb.append(entries.hasNext() ? ", " : "");
if (entries.hasNext()) {
sb.append(", ");
}
}
sb.append("}");
sb.append('}');
return sb.toString();
}
......
......@@ -177,17 +177,17 @@ final class SynthesizedMergedAnnotationInvocationHandler<A extends Annotation> i
private String annotationToString() {
String string = this.string;
if (string == null) {
StringBuilder builder = new StringBuilder("@").append(this.type.getName()).append("(");
StringBuilder builder = new StringBuilder("@").append(this.type.getName()).append('(');
for (int i = 0; i < this.attributes.size(); i++) {
Method attribute = this.attributes.get(i);
if (i > 0) {
builder.append(", ");
}
builder.append(attribute.getName());
builder.append("=");
builder.append('=');
builder.append(toString(getAttributeValue(attribute)));
}
builder.append(")");
builder.append(')');
string = builder.toString();
this.string = string;
}
......@@ -206,7 +206,7 @@ final class SynthesizedMergedAnnotationInvocationHandler<A extends Annotation> i
}
builder.append(toString(Array.get(value, i)));
}
builder.append("]");
builder.append(']');
return builder.toString();
}
return String.valueOf(value);
......
......@@ -513,7 +513,7 @@ public class TypeDescriptor implements Serializable {
public String toString() {
StringBuilder builder = new StringBuilder();
for (Annotation ann : getAnnotations()) {
builder.append("@").append(ann.annotationType().getName()).append(' ');
builder.append('@').append(ann.annotationType().getName()).append(' ');
}
builder.append(getResolvableType());
return builder.toString();
......
/*
* Copyright 2002-2020 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.
......@@ -302,7 +302,7 @@ public class StopWatch {
for (TaskInfo task : getTaskInfo()) {
sb.append(nf.format(task.getTimeNanos())).append(" ");
sb.append(pf.format((double) task.getTimeNanos() / getTotalTimeNanos())).append(" ");
sb.append(task.getTaskName()).append("\n");
sb.append(task.getTaskName()).append('\n');
}
}
return sb.toString();
......@@ -320,7 +320,7 @@ public class StopWatch {
for (TaskInfo task : getTaskInfo()) {
sb.append("; [").append(task.getTaskName()).append("] took ").append(task.getTimeNanos()).append(" ns");
long percent = Math.round(100.0 * task.getTimeNanos() / getTotalTimeNanos());
sb.append(" = ").append(percent).append("%");
sb.append(" = ").append(percent).append('%');
}
}
else {
......
/*
* Copyright 2002-2019 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.
......@@ -194,7 +194,7 @@ class FastByteArrayOutputStreamTests {
this.os.write(this.helloBytes);
InputStream inputStream = this.os.getInputStream();
DigestUtils.appendMd5DigestAsHex(inputStream, builder);
builder.append("\"");
builder.append('"');
String actual = builder.toString();
assertThat(actual).isEqualTo("\"0b10a8db164e0754105b7a99be72e3fe5\"");
}
......@@ -208,7 +208,7 @@ class FastByteArrayOutputStreamTests {
}
InputStream inputStream = this.os.getInputStream();
DigestUtils.appendMd5DigestAsHex(inputStream, builder);
builder.append("\"");
builder.append('"');
String actual = builder.toString();
assertThat(actual).isEqualTo("\"06225ca1e4533354c516e74512065331d\"");
}
......
/*
* Copyright 2002-2020 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.
......@@ -612,7 +612,7 @@ class StringUtilsTests {
StringBuilder sb = new StringBuilder();
for (int i = 0; i < components.length; i++) {
if (i != 0) {
sb.append(",");
sb.append(',');
}
sb.append(components[i]);
}
......
/*
* 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.
......@@ -137,7 +137,7 @@ public class ExpressionException extends RuntimeException {
StringBuilder output = new StringBuilder();
output.append("Expression [");
output.append(this.expressionString);
output.append("]");
output.append(']');
if (this.position >= 0) {
output.append(" @");
output.append(this.position);
......
/*
* 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.
......@@ -432,11 +432,11 @@ public class CodeFlow implements Opcodes {
public static String createSignatureDescriptor(Method method) {
Class<?>[] params = method.getParameterTypes();
StringBuilder sb = new StringBuilder();
sb.append("(");
sb.append('(');
for (Class<?> param : params) {
sb.append(toJvmDescriptor(param));
}
sb.append(")");
sb.append(')');
sb.append(toJvmDescriptor(method.getReturnType()));
return sb.toString();
}
......@@ -453,7 +453,7 @@ public class CodeFlow implements Opcodes {
public static String createSignatureDescriptor(Constructor<?> ctor) {
Class<?>[] params = ctor.getParameterTypes();
StringBuilder sb = new StringBuilder();
sb.append("(");
sb.append('(');
for (Class<?> param : params) {
sb.append(toJvmDescriptor(param));
}
......@@ -473,7 +473,7 @@ public class CodeFlow implements Opcodes {
StringBuilder sb = new StringBuilder();
if (clazz.isArray()) {
while (clazz.isArray()) {
sb.append("[");
sb.append('[');
clazz = clazz.getComponentType();
}
}
......@@ -507,9 +507,9 @@ public class CodeFlow implements Opcodes {
}
}
else {
sb.append("L");
sb.append('L');
sb.append(clazz.getName().replace('.', '/'));
sb.append(";");
sb.append(';');
}
return sb.toString();
}
......
/*
* 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.
......@@ -284,7 +284,7 @@ public enum SpelMessage {
formattedMessage.append("EL").append(this.code);
switch (this.kind) {
case ERROR:
formattedMessage.append("E");
formattedMessage.append('E');
break;
}
formattedMessage.append(": ");
......
/*
* Copyright 2002-2019 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.
......@@ -64,13 +64,13 @@ public class BeanReference extends SpelNodeImpl {
public String toStringAST() {
StringBuilder sb = new StringBuilder();
if (!this.beanName.startsWith(FACTORY_BEAN_PREFIX)) {
sb.append("@");
sb.append('@');
}
if (!this.beanName.contains(".")) {
sb.append(this.beanName);
}
else {
sb.append("'").append(this.beanName).append("'");
sb.append('\'').append(this.beanName).append('\'');
}
return sb.toString();
}
......
/*
* Copyright 2002-2019 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.
......@@ -208,14 +208,14 @@ public class ConstructorReference extends SpelNodeImpl {
StringBuilder sb = new StringBuilder("new ");
int index = 0;
sb.append(getChild(index++).toStringAST());
sb.append("(");
sb.append('(');
for (int i = index; i < getChildCount(); i++) {
if (i > index) {
sb.append(",");
sb.append(',');
}
sb.append(getChild(i).toStringAST());
}
sb.append(")");
sb.append(')');
return sb.toString();
}
......
/*
* Copyright 2002-2019 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.
......@@ -140,13 +140,13 @@ public class InlineMap extends SpelNodeImpl {
int count = getChildCount();
for (int c = 0; c < count; c++) {
if (c > 0) {
sb.append(",");
sb.append(',');
}
sb.append(getChild(c++).toStringAST());
sb.append(":");
sb.append(':');
sb.append(getChild(c).toStringAST());
}
sb.append("}");
sb.append('}');
return sb.toString();
}
......
/*
* Copyright 2002-2019 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.
......@@ -81,10 +81,10 @@ public abstract class Operator extends SpelNodeImpl {
StringBuilder sb = new StringBuilder("(");
sb.append(getChild(0).toStringAST());
for (int i = 1; i < getChildCount(); i++) {
sb.append(" ").append(getOperatorName()).append(" ");
sb.append(' ').append(getOperatorName()).append(' ');
sb.append(getChild(i).toStringAST());
}
sb.append(")");
sb.append(')');
return sb.toString();
}
......
/*
* Copyright 2002-2019 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.
......@@ -49,7 +49,7 @@ public class QualifiedIdentifier extends SpelNodeImpl {
for (int i = 0; i < getChildCount(); i++) {
Object value = this.children[i].getValueInternal(state).getValue();
if (i > 0 && (value == null || !value.toString().startsWith("$"))) {
sb.append(".");
sb.append('.');
}
sb.append(value);
}
......@@ -67,7 +67,7 @@ public class QualifiedIdentifier extends SpelNodeImpl {
else {
for (int i = 0; i < getChildCount(); i++) {
if (i > 0) {
sb.append(".");
sb.append('.');
}
sb.append(getChild(i).toStringAST());
}
......
/*
* Copyright 2002-2019 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.
......@@ -90,7 +90,7 @@ public class TypeReference extends SpelNodeImpl {
for (int d = 0; d < this.dimensions; d++) {
sb.append("[]");
}
sb.append(")");
sb.append(')');
return sb.toString();
}
......
/*
* Copyright 2002-2017 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.
......@@ -88,12 +88,12 @@ class Token {
@Override
public String toString() {
StringBuilder s = new StringBuilder();
s.append("[").append(this.kind.toString());
s.append('[').append(this.kind.toString());
if (this.kind.hasPayload()) {
s.append(":").append(this.data);
s.append(':').append(this.data);
}
s.append("]");
s.append("(").append(this.startPos).append(",").append(this.endPos).append(")");
s.append(']');
s.append('(').append(this.startPos).append(',').append(this.endPos).append(')');
return s.toString();
}
......
......@@ -245,22 +245,22 @@ public abstract class AbstractExpressionTests {
sb.append("int[").append(l.length).append("]{");
for (int j = 0; j < l.length; j++) {
if (j > 0) {
sb.append(",");
sb.append(',');
}
sb.append(stringValueOf(l[j]));
}
sb.append("}");
sb.append('}');
}
else if (primitiveType == Long.TYPE) {
long[] l = (long[]) value;
sb.append("long[").append(l.length).append("]{");
for (int j = 0; j < l.length; j++) {
if (j > 0) {
sb.append(",");
sb.append(',');
}
sb.append(stringValueOf(l[j]));
}
sb.append("}");
sb.append('}');
}
else {
throw new RuntimeException("Please implement support for type " + primitiveType.getName() +
......@@ -272,32 +272,32 @@ public abstract class AbstractExpressionTests {
if (!isNested) {
sb.append(value.getClass().getComponentType().getName());
}
sb.append("[").append(l.size()).append("]{");
sb.append('[').append(l.size()).append("]{");
int i = 0;
for (Object object : l) {
if (i > 0) {
sb.append(",");
sb.append(',');
}
i++;
sb.append(stringValueOf(object, true));
}
sb.append("}");
sb.append('}');
}
else {
List<Object> l = Arrays.asList((Object[]) value);
if (!isNested) {
sb.append(value.getClass().getComponentType().getName());
}
sb.append("[").append(l.size()).append("]{");
sb.append('[').append(l.size()).append("]{");
int i = 0;
for (Object object : l) {
if (i > 0) {
sb.append(",");
sb.append(',');
}
i++;
sb.append(stringValueOf(object));
}
sb.append("}");
sb.append('}');
}
return sb.toString();
}
......
/*
* Copyright 2002-2020 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.
......@@ -5111,21 +5111,21 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
List<?> ls = (List<?>) object;
for (Object l: ls) {
s.append(l);
s.append(" ");
s.append(' ');
}
}
else if (object instanceof Object[]) {
Object[] os = (Object[]) object;
for (Object o: os) {
s.append(o);
s.append(" ");
s.append(' ');
}
}
else if (object instanceof int[]) {
int[] is = (int[]) object;
for (int i: is) {
s.append(i);
s.append(" ");
s.append(' ');
}
}
else {
......@@ -5931,9 +5931,9 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
public Obj3(String s, Float f, int... ints) {
StringBuilder b = new StringBuilder();
b.append(s);
b.append(":");
b.append(':');
b.append(Float.toString(f));
b.append(":");
b.append(':');
for (int param: ints) {
b.append(Integer.toString(param));
}
......
/*
* Copyright 2002-2020 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.
......@@ -646,13 +646,13 @@ public class CallMetaDataContext {
}
if (StringUtils.hasLength(catalogNameToUse)) {
callString.append(catalogNameToUse).append(".");
callString.append(catalogNameToUse).append('.');
}
if (StringUtils.hasLength(schemaNameToUse)) {
callString.append(schemaNameToUse).append(".");
callString.append(schemaNameToUse).append('.');
}
callString.append(this.metaDataProvider.procedureNameToUse(getProcedureName()));
callString.append("(");
callString.append('(');
for (SqlParameter parameter : this.callParameters) {
if (!parameter.isResultsParameter()) {
......
......@@ -280,7 +280,7 @@ public class TableMetaDataContext {
insertStatement.append("INSERT INTO ");
if (getSchemaName() != null) {
insertStatement.append(getSchemaName());
insertStatement.append(".");
insertStatement.append('.');
}
insertStatement.append(getTableName());
insertStatement.append(" (");
......@@ -313,7 +313,7 @@ public class TableMetaDataContext {
}
String params = String.join(", ", Collections.nCopies(columnCount, "?"));
insertStatement.append(params);
insertStatement.append(")");
insertStatement.append(')');
return insertStatement.toString();
}
......
/*
* Copyright 2002-2020 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.
......@@ -186,10 +186,10 @@ public class TransactionAwareDataSourceProxy extends DelegatingDataSource {
// Allow for differentiating between the proxy and the raw Connection.
StringBuilder sb = new StringBuilder("Transaction-aware proxy for target Connection ");
if (this.target != null) {
sb.append("[").append(this.target.toString()).append("]");
sb.append('[').append(this.target.toString()).append(']');
}
else {
sb.append(" from DataSource [").append(this.targetDataSource).append("]");
sb.append(" from DataSource [").append(this.targetDataSource).append(']');
}
return sb.toString();
case "close":
......
/*
* 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.
......@@ -152,7 +152,7 @@ public abstract class AbstractIdentityColumnMaxValueIncrementer extends Abstract
for (int i = 0; i < values.length - 1; i++) {
sb.append(", ").append(values[i]);
}
sb.append(")");
sb.append(')');
}
else {
long maxValue = values[values.length - 1];
......
......@@ -177,9 +177,9 @@ public abstract class AbstractJmsListenerEndpoint implements JmsListenerEndpoint
*/
protected StringBuilder getEndpointDescription() {
StringBuilder result = new StringBuilder();
return result.append(getClass().getSimpleName()).append("[").append(this.id).append("] destination=").
return result.append(getClass().getSimpleName()).append('[').append(this.id).append("] destination=").
append(this.destination).append("' | subscription='").append(this.subscription).
append(" | selector='").append(this.selector).append("'");
append(" | selector='").append(this.selector).append('\'');
}
@Override
......
/*
* Copyright 2002-2019 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.
......@@ -224,8 +224,8 @@ public class MethodJmsListenerEndpoint extends AbstractJmsListenerEndpoint imple
@Override
protected StringBuilder getEndpointDescription() {
return super.getEndpointDescription()
.append(" | bean='").append(this.bean).append("'")
.append(" | method='").append(this.method).append("'");
.append(" | bean='").append(this.bean).append('\'')
.append(" | method='").append(this.method).append('\'');
}
}
/*
* Copyright 2002-2017 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.
......@@ -63,7 +63,7 @@ public class SimpleJmsListenerEndpoint extends AbstractJmsListenerEndpoint {
@Override
protected StringBuilder getEndpointDescription() {
return super.getEndpointDescription()
.append(" | messageListener='").append(this.messageListener).append("'");
.append(" | messageListener='").append(this.messageListener).append('\'');
}
}
/*
* Copyright 2002-2017 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.
......@@ -125,7 +125,7 @@ public class MessagingMessageListenerAdapter extends AbstractAdaptableMessageLis
private String createMessagingErrorMessage(String description) {
InvocableHandlerMethod handlerMethod = getHandlerMethod();
StringBuilder sb = new StringBuilder(description).append("\n")
StringBuilder sb = new StringBuilder(description).append('\n')
.append("Endpoint handler details:\n")
.append("Method [").append(handlerMethod.getMethod()).append("]\n")
.append("Bean [").append(handlerMethod.getBean()).append("]\n");
......
/*
* Copyright 2002-2019 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.
......@@ -70,7 +70,7 @@ public class MethodArgumentNotValidException extends MethodArgumentResolutionExc
StringBuilder sb = new StringBuilder();
sb.append(bindingResult.getErrorCount()).append(" error(s): ");
for (ObjectError error : bindingResult.getAllErrors()) {
sb.append("[").append(error).append("] ");
sb.append('[').append(error).append("] ");
}
return sb.toString();
}
......
/*
* Copyright 2002-2019 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.
......@@ -208,7 +208,7 @@ public class SimpMessageHeaderAccessor extends NativeMessageHeaderAccessor {
}
StringBuilder sb = getBaseLogMessage();
if (!CollectionUtils.isEmpty(getSessionAttributes())) {
sb.append(" attributes[").append(getSessionAttributes().size()).append("]");
sb.append(" attributes[").append(getSessionAttributes().size()).append(']');
}
sb.append(getShortPayloadLogMessage(payload));
return sb.toString();
......
/*
* Copyright 2002-2019 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.
......@@ -452,7 +452,7 @@ public class StompHeaderAccessor extends SimpMessageHeaderAccessor {
return super.getDetailedLogMessage(payload);
}
StringBuilder sb = new StringBuilder();
sb.append(command.name()).append(" ");
sb.append(command.name()).append(' ');
Map<String, List<String>> nativeHeaders = getNativeHeaders();
if (nativeHeaders != null) {
sb.append(nativeHeaders);
......
/*
* 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.
......@@ -112,12 +112,12 @@ public class GenericMessage<T> implements Message<T>, Serializable {
StringBuilder sb = new StringBuilder(getClass().getSimpleName());
sb.append(" [payload=");
if (this.payload instanceof byte[]) {
sb.append("byte[").append(((byte[]) this.payload).length).append("]");
sb.append("byte[").append(((byte[]) this.payload).length).append(']');
}
else {
sb.append(this.payload);
}
sb.append(", headers=").append(this.headers).append("]");
sb.append(", headers=").append(this.headers).append(']');
return sb.toString();
}
......
/*
* Copyright 2002-2019 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.
......@@ -241,7 +241,7 @@ public class StompHeaderAccessorTests {
StringBuilder sb = new StringBuilder();
for (int i = 0; i < 80; i++) {
sb.append("a");
sb.append('a');
}
final String payload = sb.toString() + " > 80";
actual = accessor.getShortLogMessage(payload.getBytes(StandardCharsets.UTF_8));
......
/*
* Copyright 2002-2020 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.
......@@ -320,7 +320,7 @@ public class MessageHeaderAccessorTests {
StringBuilder sb = new StringBuilder();
for (int i = 0; i < 80; i++) {
sb.append("a");
sb.append('a');
}
final String payload = sb.toString() + " > 80";
......@@ -356,7 +356,7 @@ public class MessageHeaderAccessorTests {
StringBuilder sb = new StringBuilder();
for (int i = 0; i < 80; i++) {
sb.append("a");
sb.append('a');
}
final String payload = sb.toString() + " > 80";
......
/*
* Copyright 2002-2017 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.
......@@ -126,7 +126,7 @@ public class MockClientHttpRequest extends MockHttpOutputMessage implements Clie
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(this.httpMethod);
sb.append(" ").append(this.uri);
sb.append(' ').append(this.uri);
if (!getHeaders().isEmpty()) {
sb.append(", headers: ").append(getHeaders());
}
......
......@@ -193,7 +193,7 @@ public abstract class AbstractRequestExpectationManager implements RequestExpect
if (!this.requests.isEmpty()) {
sb.append(":\n");
for (ClientHttpRequest request : this.requests) {
sb.append(request.toString()).append("\n");
sb.append(request.toString()).append('\n');
}
}
else {
......
/*
* Copyright 2002-2020 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.
......@@ -231,7 +231,7 @@ public class DefaultTransactionAttribute extends DefaultTransactionDefinition im
protected final StringBuilder getAttributeDescription() {
StringBuilder result = getDefinitionDescription();
if (StringUtils.hasText(this.qualifier)) {
result.append("; '").append(this.qualifier).append("'");
result.append("; '").append(this.qualifier).append('\'');
}
if (!this.labels.isEmpty()) {
result.append("; ").append(this.labels);
......
/*
* Copyright 2002-2020 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.
......@@ -147,7 +147,7 @@ public class ServerSentEventHttpMessageReader implements HttpMessageReader<Objec
for (String line : lines) {
if (line.startsWith("data:")) {
data = (data != null ? data : new StringBuilder());
data.append(line.substring(5).trim()).append("\n");
data.append(line.substring(5).trim()).append('\n');
}
if (shouldWrap) {
if (line.startsWith("id:")) {
......@@ -161,7 +161,7 @@ public class ServerSentEventHttpMessageReader implements HttpMessageReader<Objec
}
else if (line.startsWith(":")) {
comment = (comment != null ? comment : new StringBuilder());
comment.append(line.substring(1).trim()).append("\n");
comment.append(line.substring(1).trim()).append('\n');
}
}
}
......
......@@ -141,7 +141,7 @@ public class ServerSentEventHttpMessageWriter implements HttpMessageWriter<Objec
writeField("retry", retry.toMillis(), sb);
}
if (comment != null) {
sb.append(':').append(StringUtils.replace(comment, "\n", "\n:")).append("\n");
sb.append(':').append(StringUtils.replace(comment, "\n", "\n:")).append('\n');
}
if (data != null) {
sb.append("data:");
......@@ -181,7 +181,7 @@ public class ServerSentEventHttpMessageWriter implements HttpMessageWriter<Objec
}
private void writeField(String fieldName, Object fieldValue, StringBuilder sb) {
sb.append(fieldName).append(':').append(fieldValue).append("\n");
sb.append(fieldName).append(':').append(fieldValue).append('\n');
}
private DataBuffer encodeText(CharSequence text, MediaType mediaType, DataBufferFactory bufferFactory) {
......
/*
* Copyright 2002-2020 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.
......@@ -64,7 +64,7 @@ public class MethodArgumentNotValidException extends BindException {
}
sb.append(": ");
for (ObjectError error : bindingResult.getAllErrors()) {
sb.append("[").append(error).append("] ");
sb.append('[').append(error).append("] ");
}
return sb.toString();
}
......
/*
* 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.
......@@ -77,9 +77,9 @@ public class UnsatisfiedServletRequestParameterException extends ServletRequestB
if (i > 0) {
sb.append(" OR ");
}
sb.append("\"");
sb.append('"');
sb.append(StringUtils.arrayToDelimitedString(conditions, ", "));
sb.append("\"");
sb.append('"');
i++;
}
sb.append(" not met for actual request parameters: ");
......
/*
* Copyright 2002-2020 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.
......@@ -289,7 +289,7 @@ public class WebExchangeBindException extends ServerWebInputException implements
.append(parameter.getExecutable().toGenericString())
.append(", with ").append(this.bindingResult.getErrorCount()).append(" error(s): ");
for (ObjectError error : this.bindingResult.getAllErrors()) {
sb.append("[").append(error).append("] ");
sb.append('[').append(error).append("] ");
}
return sb.toString();
}
......
/*
* Copyright 2002-2019 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.
......@@ -322,7 +322,7 @@ public abstract class AbstractRequestLoggingFilter extends OncePerRequestFilter
protected String createMessage(HttpServletRequest request, String prefix, String suffix) {
StringBuilder msg = new StringBuilder();
msg.append(prefix);
msg.append(request.getMethod()).append(" ");
msg.append(request.getMethod()).append(' ');
msg.append(request.getRequestURI());
if (isIncludeQueryString()) {
......
/*
* 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.
......@@ -333,7 +333,7 @@ public class ModelAndViewContainer {
StringBuilder sb = new StringBuilder("ModelAndViewContainer: ");
if (!isRequestHandled()) {
if (isViewReference()) {
sb.append("reference to view with name '").append(this.view).append("'");
sb.append("reference to view with name '").append(this.view).append('\'');
}
else {
sb.append("View is [").append(this.view).append(']');
......
/*
* 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.
......@@ -159,12 +159,12 @@ class CaptureVariablePathElement extends PathElement {
@Override
public char[] getChars() {
StringBuilder b = new StringBuilder();
b.append("{");
b.append('{');
b.append(this.variableName);
if (this.constraintPattern != null) {
b.append(":").append(this.constraintPattern.pattern());
b.append(':').append(this.constraintPattern.pattern());
}
b.append("}");
b.append('}');
return b.toString().toCharArray();
}
......
/*
* Copyright 2002-2019 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.
......@@ -111,7 +111,7 @@ public class HttpRangeTests {
// 1. At limit..
StringBuilder atLimit = new StringBuilder("bytes=0-0");
for (int i=0; i < 99; i++) {
atLimit.append(",").append(i).append("-").append(i + 1);
atLimit.append(',').append(i).append('-').append(i + 1);
}
List<HttpRange> ranges = HttpRange.parseRanges(atLimit.toString());
assertThat(ranges.size()).isEqualTo(100);
......@@ -119,7 +119,7 @@ public class HttpRangeTests {
// 2. Above limit..
StringBuilder aboveLimit = new StringBuilder("bytes=0-0");
for (int i=0; i < 100; i++) {
aboveLimit.append(",").append(i).append("-").append(i + 1);
aboveLimit.append(',').append(i).append('-').append(i + 1);
}
assertThatIllegalArgumentException().isThrownBy(() ->
HttpRange.parseRanges(aboveLimit.toString()));
......
/*
* Copyright 2002-2019 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.
......@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.web.multipart.support;
import java.util.HashMap;
......@@ -80,7 +81,7 @@ public class DefaultMultipartHttpServletRequestTests {
for (String key : this.queryParams.keySet()) {
for (String value : this.queryParams.get(key)) {
this.servletRequest.addParameter(key, value);
query.append(query.length() > 0 ? "&" : "").append(key).append("=").append(value);
query.append(query.length() > 0 ? "&" : "").append(key).append('=').append(value);
}
}
this.servletRequest.setQueryString(query.toString());
......
/*
* Copyright 2004-2019 the original author or authors.
* Copyright 2004-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.
......@@ -33,15 +33,15 @@ public class JavaScriptUtilsTests {
public void escape() {
StringBuilder sb = new StringBuilder();
sb.append('"');
sb.append("'");
sb.append("\\");
sb.append("/");
sb.append("\t");
sb.append("\n");
sb.append("\r");
sb.append("\f");
sb.append("\b");
sb.append("\013");
sb.append('\'');
sb.append('\\');
sb.append('/');
sb.append('\t');
sb.append('\n');
sb.append('\r');
sb.append('\f');
sb.append('\b');
sb.append('\013');
assertThat(JavaScriptUtils.javaScriptEscape(sb.toString())).isEqualTo("\\\"\\'\\\\\\/\\t\\n\\n\\f\\b\\v");
}
......
/*
* Copyright 2002-2020 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.
......@@ -1210,7 +1210,7 @@ public class PathPatternTests {
private String elementsToString(List<Element> elements) {
StringBuilder s = new StringBuilder();
for (Element element: elements) {
s.append("[").append(element.value()).append("]");
s.append('[').append(element.value()).append(']');
}
return s.toString();
}
......
......@@ -380,7 +380,7 @@ public final class RequestMappingInfo implements RequestCondition<RequestMapping
}
if (!this.patternsCondition.isEmpty()) {
Set<PathPattern> patterns = this.patternsCondition.getPatterns();
builder.append(" ").append(patterns.size() == 1 ? patterns.iterator().next() : patterns);
builder.append(' ').append(patterns.size() == 1 ? patterns.iterator().next() : patterns);
}
if (!this.paramsCondition.isEmpty()) {
builder.append(", params ").append(this.paramsCondition);
......
/*
* 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.
......@@ -353,7 +353,7 @@ public class BindStatus {
public String toString() {
StringBuilder sb = new StringBuilder("BindStatus: ");
sb.append("expression=[").append(this.expression).append("]; ");
sb.append("value=[").append(this.value).append("]");
sb.append("value=[").append(this.value).append(']');
if (!ObjectUtils.isEmpty(this.errorCodes)) {
sb.append("; errorCodes=").append(Arrays.asList(this.errorCodes));
}
......
/*
* Copyright 2002-2019 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.
......@@ -154,7 +154,7 @@ class FlushingIntegrationTests extends AbstractHttpHandlerIntegrationTests {
for (char c : "0123456789".toCharArray()) {
sb.append(c);
if (sb.length() + 1 == 1024) {
sink.next(sb.append("\n").toString());
sink.next(sb.append('\n').toString());
return;
}
}
......
......@@ -509,7 +509,7 @@ public final class RequestMappingInfo implements RequestCondition<RequestMapping
}
// Patterns conditions are never empty and have "" (empty path) at least.
builder.append(" ").append(getActivePatternsCondition());
builder.append(' ').append(getActivePatternsCondition());
if (!this.paramsCondition.isEmpty()) {
builder.append(", params ").append(this.paramsCondition);
......
/*
* Copyright 2002-2020 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.
......@@ -35,6 +35,7 @@ import org.springframework.util.StringUtils;
*
* @author Rossen Stoyanchev
* @author Juergen Hoeller
* @author Sam Brannen
* @since 4.2
*/
public class SseEmitter extends ResponseBodyEmitter {
......@@ -175,7 +176,7 @@ public class SseEmitter extends ResponseBodyEmitter {
SseEventBuilder data(Object object, @Nullable MediaType mediaType);
/**
* Return one or more Object-MediaType pairs to write via
* Return one or more Object-MediaType pairs to write via
* {@link #send(Object, MediaType)}.
* @since 4.2.3
*/
......@@ -195,25 +196,25 @@ public class SseEmitter extends ResponseBodyEmitter {
@Override
public SseEventBuilder id(String id) {
append("id:").append(id).append("\n");
append("id:").append(id).append('\n');
return this;
}
@Override
public SseEventBuilder name(String name) {
append("event:").append(name).append("\n");
append("event:").append(name).append('\n');
return this;
}
@Override
public SseEventBuilder reconnectTime(long reconnectTimeMillis) {
append("retry:").append(String.valueOf(reconnectTimeMillis)).append("\n");
append("retry:").append(String.valueOf(reconnectTimeMillis)).append('\n');
return this;
}
@Override
public SseEventBuilder comment(String comment) {
append(":").append(comment).append("\n");
append(':').append(comment).append('\n');
return this;
}
......@@ -227,7 +228,7 @@ public class SseEmitter extends ResponseBodyEmitter {
append("data:");
saveAppendedText();
this.dataToSend.add(new DataWithMediaType(object, mediaType));
append("\n");
append('\n');
return this;
}
......@@ -239,12 +240,20 @@ public class SseEmitter extends ResponseBodyEmitter {
return this;
}
SseEventBuilderImpl append(char ch) {
if (this.sb == null) {
this.sb = new StringBuilder();
}
this.sb.append(ch);
return this;
}
@Override
public Set<DataWithMediaType> build() {
if (!StringUtils.hasLength(this.sb) && this.dataToSend.isEmpty()) {
return Collections.emptySet();
}
append("\n");
append('\n');
saveAppendedText();
return this.dataToSend;
}
......
......@@ -268,7 +268,7 @@ public class PathResourceResolver extends AbstractResourceResolver {
while (tokenizer.hasMoreTokens()) {
String value = UriUtils.encode(tokenizer.nextToken(), charset);
sb.append(value);
sb.append("/");
sb.append('/');
}
if (!path.endsWith("/")) {
sb.setLength(sb.length() - 1);
......
/*
* 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.
......@@ -352,7 +352,7 @@ public class BindStatus {
public String toString() {
StringBuilder sb = new StringBuilder("BindStatus: ");
sb.append("expression=[").append(this.expression).append("]; ");
sb.append("value=[").append(this.value).append("]");
sb.append("value=[").append(this.value).append(']');
if (!ObjectUtils.isEmpty(this.errorCodes)) {
sb.append("; errorCodes=").append(Arrays.asList(this.errorCodes));
}
......
/*
* Copyright 2002-2020 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.
......@@ -286,7 +286,7 @@ public class UrlTag extends HtmlEscapingAwareTag implements ParamAware {
}
}
if (this.type != UrlType.RELATIVE && this.type != UrlType.ABSOLUTE && !this.value.startsWith("/")) {
url.append("/");
url.append('/');
}
url.append(replaceUriTemplateParams(this.value, this.params, this.templateParams));
url.append(createQueryString(this.params, this.templateParams, (url.indexOf("?") == -1)));
......@@ -324,15 +324,15 @@ public class UrlTag extends HtmlEscapingAwareTag implements ParamAware {
for (Param param : params) {
if (!usedParams.contains(param.getName()) && StringUtils.hasLength(param.getName())) {
if (includeQueryStringDelimiter && qs.length() == 0) {
qs.append("?");
qs.append('?');
}
else {
qs.append("&");
qs.append('&');
}
try {
qs.append(UriUtils.encodeQueryParam(param.getName(), encoding));
if (param.getValue() != null) {
qs.append("=");
qs.append('=');
qs.append(UriUtils.encodeQueryParam(param.getValue(), encoding));
}
}
......
/*
* Copyright 2002-2019 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.
......@@ -75,7 +75,7 @@ public class HtmlFileTransportHandler extends AbstractHttpSendingTransportHandle
);
while (sb.length() < MINIMUM_PARTIAL_HTML_CONTENT_LENGTH) {
sb.append(" ");
sb.append(' ');
}
PARTIAL_HTML_CONTENT = sb.toString();
}
......
/*
* Copyright 2002-2016 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.
......@@ -56,15 +56,15 @@ public class StompTextMessageBuilder {
}
public TextMessage build() {
StringBuilder sb = new StringBuilder(this.command.name()).append("\n");
StringBuilder sb = new StringBuilder(this.command.name()).append('\n');
for (String line : this.headerLines) {
sb.append(line).append("\n");
sb.append(line).append('\n');
}
sb.append("\n");
sb.append('\n');
if (this.body != null) {
sb.append(this.body);
}
sb.append("\u0000");
sb.append('\u0000');
return new TextMessage(sb.toString());
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册