提交 29f382b0 编写于 作者: S stsypanov 提交者: Juergen Hoeller

Simplify String concatenation

上级 9d2e7ced
......@@ -150,9 +150,7 @@ public class BeanDefinitionHolder implements BeanMetadataElement {
* @see #getBeanDefinition()
*/
public String getLongDescription() {
StringBuilder sb = new StringBuilder(getShortDescription());
sb.append(": ").append(this.beanDefinition);
return sb.toString();
return getShortDescription() + ": " + this.beanDefinition;
}
/**
......
......@@ -965,13 +965,10 @@ public class ResolvableType implements Serializable {
return "?";
}
}
StringBuilder result = new StringBuilder(this.resolved.getName());
if (hasGenerics()) {
result.append('<');
result.append(StringUtils.arrayToDelimitedString(getGenerics(), ", "));
result.append('>');
return this.resolved.getName() + '<' + StringUtils.arrayToDelimitedString(getGenerics(), ", ") + '>';
}
return result.toString();
return this.resolved.getName();
}
......
......@@ -205,19 +205,16 @@ public class Selection extends SpelNodeImpl {
@Override
public String toStringAST() {
StringBuilder sb = new StringBuilder();
return prefix() + getChild(0).toStringAST() + "]";
}
private String prefix() {
switch (this.variant) {
case ALL:
sb.append("?[");
break;
case FIRST:
sb.append("^[");
break;
case LAST:
sb.append("$[");
break;
case ALL: return "?[";
case FIRST: return "^[";
case LAST: return "$[";
}
return sb.append(getChild(0).toStringAST()).append("]").toString();
return "";
}
}
......@@ -403,12 +403,11 @@ public class MockHttpServletRequest implements HttpServletRequest {
private void updateContentTypeHeader() {
if (StringUtils.hasLength(this.contentType)) {
StringBuilder sb = new StringBuilder(this.contentType);
if (!this.contentType.toLowerCase().contains(CHARSET_PREFIX) &&
StringUtils.hasLength(this.characterEncoding)) {
sb.append(";").append(CHARSET_PREFIX).append(this.characterEncoding);
String value = this.contentType;
if (StringUtils.hasLength(this.characterEncoding) && !this.contentType.toLowerCase().contains(CHARSET_PREFIX)) {
value += ';' + CHARSET_PREFIX + this.characterEncoding;
}
doAddHeaderValue(HttpHeaders.CONTENT_TYPE, sb.toString(), true);
doAddHeaderValue(HttpHeaders.CONTENT_TYPE, value, true);
}
}
......
......@@ -108,12 +108,10 @@ abstract class AbstractMediaTypeExpression implements Comparable<AbstractMediaTy
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
if (this.isNegated) {
builder.append('!');
return '!' + this.mediaType.toString();
}
builder.append(this.mediaType.toString());
return builder.toString();
return this.mediaType.toString();
}
}
......@@ -92,12 +92,10 @@ abstract class AbstractMediaTypeExpression implements MediaTypeExpression, Compa
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
if (this.isNegated) {
builder.append('!');
return '!' + this.mediaType.toString();
}
builder.append(this.mediaType.toString());
return builder.toString();
return this.mediaType.toString();
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册