Polishing

This commit is contained in:
Sam Brannen
2022-12-06 12:29:03 -05:00
parent f64397d822
commit 9f7a510f90
20 changed files with 60 additions and 57 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2022 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.
@@ -98,7 +98,7 @@ final class DefaultRenderingResponseBuilder implements RenderingResponse.Builder
@Override
public RenderingResponse.Builder modelAttribute(Object attribute) {
Assert.notNull(attribute, "Attribute must not be null");
if (attribute instanceof Collection && ((Collection<?>) attribute).isEmpty()) {
if (attribute instanceof Collection<?> collection && collection.isEmpty()) {
return this;
}
return modelAttribute(Conventions.getVariableName(attribute), attribute);

View File

@@ -337,8 +337,8 @@ public class RequestMappingHandlerMapping extends RequestMappingInfoHandlerMappi
@Nullable
private RequestMappingInfo createRequestMappingInfo(AnnotatedElement element) {
RequestMapping requestMapping = AnnotatedElementUtils.findMergedAnnotation(element, RequestMapping.class);
RequestCondition<?> condition = (element instanceof Class ?
getCustomTypeCondition((Class<?>) element) : getCustomMethodCondition((Method) element));
RequestCondition<?> condition = (element instanceof Class<?> clazz ?
getCustomTypeCondition(clazz) : getCustomMethodCondition((Method) element));
return (requestMapping != null ? createRequestMappingInfo(requestMapping, condition) : null);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2021 the original author or authors.
* Copyright 2002-2022 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.
@@ -128,8 +128,8 @@ public class BindStatus {
this.objectErrors = this.errors.getFieldErrors(this.expression);
this.value = this.errors.getFieldValue(this.expression);
this.valueType = this.errors.getFieldType(this.expression);
if (this.errors instanceof BindingResult) {
this.bindingResult = (BindingResult) this.errors;
if (this.errors instanceof BindingResult br) {
this.bindingResult = br;
this.actualValue = this.bindingResult.getRawFieldValue(this.expression);
this.editor = this.bindingResult.findEditor(this.expression, null);
}
@@ -163,8 +163,8 @@ public class BindStatus {
this.errorMessages = new String[0];
}
if (htmlEscape && this.value instanceof String) {
this.value = HtmlUtils.htmlEscape((String) this.value);
if (htmlEscape && this.value instanceof String text) {
this.value = HtmlUtils.htmlEscape(text);
}
}
@@ -239,8 +239,8 @@ public class BindStatus {
* will get HTML-escaped.
*/
public String getDisplayValue() {
if (this.value instanceof String) {
return (String) this.value;
if (this.value instanceof String displayValue) {
return displayValue;
}
if (this.value != null) {
return (this.htmlEscape ? HtmlUtils.htmlEscape(this.value.toString()) : this.value.toString());