From 9f7a510f9027f4a2c29072e7e51156d765337638 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Tue, 6 Dec 2022 12:29:03 -0500 Subject: [PATCH] Polishing --- .../reactive/MultipartIntegrationTests.java | 17 +++++++------- .../config/ResourceHandlerRegistry.java | 2 +- .../client/DefaultClientResponse.java | 8 +++---- .../DefaultRenderingResponseBuilder.java | 2 +- .../server/PathResourceLookupFunction.java | 2 +- .../handler/SimpleUrlHandlerMapping.java | 2 +- .../resource/EncodedResourceResolver.java | 2 +- .../ModelAttributeMethodArgumentResolver.java | 4 ++-- .../RequestMappingHandlerMapping.java | 6 ++--- ...rverWebExchangeMethodArgumentResolver.java | 2 +- .../web/reactive/result/view/BindStatus.java | 14 ++++++------ .../result/view/UrlBasedViewResolver.java | 2 +- .../view/ViewResolutionResultHandler.java | 2 +- .../function/MultipartIntegrationTests.java | 2 +- .../web/reactive/protobuf/Msg.java | 22 ++++++++++--------- .../web/reactive/protobuf/SecondMsg.java | 4 ++-- .../annotation/MultipartIntegrationTests.java | 2 +- .../DefaultRenderingResponseBuilder.java | 4 ++-- .../RequestMappingHandlerMapping.java | 4 ++-- .../web/servlet/support/BindStatus.java | 14 ++++++------ 20 files changed, 60 insertions(+), 57 deletions(-) diff --git a/spring-web/src/test/java/org/springframework/http/server/reactive/MultipartIntegrationTests.java b/spring-web/src/test/java/org/springframework/http/server/reactive/MultipartIntegrationTests.java index 9af1a1397d..5da11eb541 100644 --- a/spring-web/src/test/java/org/springframework/http/server/reactive/MultipartIntegrationTests.java +++ b/spring-web/src/test/java/org/springframework/http/server/reactive/MultipartIntegrationTests.java @@ -42,6 +42,7 @@ import org.springframework.web.testfixture.http.server.reactive.bootstrap.Abstra import org.springframework.web.testfixture.http.server.reactive.bootstrap.HttpServer; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.InstanceOfAssertFactories.type; /** * @author Sebastien Deleuze @@ -95,9 +96,9 @@ class MultipartIntegrationTests extends AbstractHttpHandlerIntegrationTests { .getMultipartData() .doOnNext(parts -> { assertThat(parts).hasSize(2); - assertThat(parts.containsKey("fooPart")).isTrue(); + assertThat(parts).containsKey("fooPart"); assertFooPart(parts.getFirst("fooPart")); - assertThat(parts.containsKey("barPart")).isTrue(); + assertThat(parts).containsKey("barPart"); assertBarPart(parts.getFirst("barPart")); }) .then(); @@ -105,9 +106,9 @@ class MultipartIntegrationTests extends AbstractHttpHandlerIntegrationTests { private void assertFooPart(Part part) { assertThat(part.name()).isEqualTo("fooPart"); - boolean condition = part instanceof FilePart; - assertThat(condition).isTrue(); - assertThat(((FilePart) part).filename()).isEqualTo("foo.txt"); + assertThat(part) + .asInstanceOf(type(FilePart.class)) + .extracting(FilePart::filename).isEqualTo("foo.txt"); StepVerifier.create(DataBufferUtils.join(part.content())) .consumeNextWith(buffer -> { @@ -121,9 +122,9 @@ class MultipartIntegrationTests extends AbstractHttpHandlerIntegrationTests { private void assertBarPart(Part part) { assertThat(part.name()).isEqualTo("barPart"); - boolean condition = part instanceof FormFieldPart; - assertThat(condition).isTrue(); - assertThat(((FormFieldPart) part).value()).isEqualTo("bar"); + assertThat(part) + .asInstanceOf(type(FormFieldPart.class)) + .extracting(FormFieldPart::value).isEqualTo("bar"); } } diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/config/ResourceHandlerRegistry.java b/spring-webflux/src/main/java/org/springframework/web/reactive/config/ResourceHandlerRegistry.java index 3c1475ee24..a712bf4b9b 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/config/ResourceHandlerRegistry.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/config/ResourceHandlerRegistry.java @@ -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. diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultClientResponse.java b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultClientResponse.java index 67f8a81644..53f7e7ca80 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultClientResponse.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultClientResponse.java @@ -133,11 +133,11 @@ class DefaultClientResponse implements ClientResponse { public T body(BodyExtractor extractor) { T result = extractor.extract(this.response, this.bodyExtractorContext); String description = "Body from " + this.requestDescription + " [DefaultClientResponse]"; - if (result instanceof Mono monoResult) { - return (T) monoResult.checkpoint(description); + if (result instanceof Mono mono) { + return (T) mono.checkpoint(description); } - else if (result instanceof Flux fluxResult) { - return (T) fluxResult.checkpoint(description); + else if (result instanceof Flux flux) { + return (T) flux.checkpoint(description); } else { return result; diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/DefaultRenderingResponseBuilder.java b/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/DefaultRenderingResponseBuilder.java index 59886ba6a8..a947d25d1b 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/DefaultRenderingResponseBuilder.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/DefaultRenderingResponseBuilder.java @@ -107,7 +107,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 attrCollection && attrCollection.isEmpty()) { + if (attribute instanceof Collection collection && collection.isEmpty()) { return this; } return modelAttribute(Conventions.getVariableName(attribute), attribute); diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/PathResourceLookupFunction.java b/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/PathResourceLookupFunction.java index f302076bc3..86e3157388 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/PathResourceLookupFunction.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/PathResourceLookupFunction.java @@ -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. diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/handler/SimpleUrlHandlerMapping.java b/spring-webflux/src/main/java/org/springframework/web/reactive/handler/SimpleUrlHandlerMapping.java index 20567662cb..bf83751cd2 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/handler/SimpleUrlHandlerMapping.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/handler/SimpleUrlHandlerMapping.java @@ -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. diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/resource/EncodedResourceResolver.java b/spring-webflux/src/main/java/org/springframework/web/reactive/resource/EncodedResourceResolver.java index a9955f645b..5750df7148 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/resource/EncodedResourceResolver.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/resource/EncodedResourceResolver.java @@ -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. diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/ModelAttributeMethodArgumentResolver.java b/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/ModelAttributeMethodArgumentResolver.java index 5ae0a3f2d3..24a0eaf3c2 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/ModelAttributeMethodArgumentResolver.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/ModelAttributeMethodArgumentResolver.java @@ -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. @@ -247,7 +247,7 @@ public class ModelAttributeMethodArgumentResolver extends HandlerMethodArgumentR } } } - value = (value instanceof List valueList ? valueList.toArray() : value); + value = (value instanceof List list ? list.toArray() : value); MethodParameter methodParam = new MethodParameter(ctor, i); if (value == null && methodParam.isOptional()) { args[i] = (methodParam.getParameterType() == Optional.class ? Optional.empty() : null); diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/RequestMappingHandlerMapping.java b/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/RequestMappingHandlerMapping.java index f4873ea0c9..174e2fa4d7 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/RequestMappingHandlerMapping.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/RequestMappingHandlerMapping.java @@ -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. @@ -177,8 +177,8 @@ public class RequestMappingHandlerMapping extends RequestMappingInfoHandlerMappi @Nullable private RequestMappingInfo createRequestMappingInfo(AnnotatedElement element) { RequestMapping requestMapping = AnnotatedElementUtils.findMergedAnnotation(element, RequestMapping.class); - RequestCondition condition = (element instanceof Class typeElement ? - getCustomTypeCondition(typeElement) : getCustomMethodCondition((Method) element)); + RequestCondition condition = (element instanceof Class clazz ? + getCustomTypeCondition(clazz) : getCustomMethodCondition((Method) element)); return (requestMapping != null ? createRequestMappingInfo(requestMapping, condition) : null); } diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/ServerWebExchangeMethodArgumentResolver.java b/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/ServerWebExchangeMethodArgumentResolver.java index 81bcbcceaf..8837aea441 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/ServerWebExchangeMethodArgumentResolver.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/ServerWebExchangeMethodArgumentResolver.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 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. diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/result/view/BindStatus.java b/spring-webflux/src/main/java/org/springframework/web/reactive/result/view/BindStatus.java index 5d8a40c718..91b3a6ca2f 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/result/view/BindStatus.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/result/view/BindStatus.java @@ -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. @@ -126,8 +126,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 bindingResultError) { - this.bindingResult = bindingResultError; + if (this.errors instanceof BindingResult br) { + this.bindingResult = br; this.actualValue = this.bindingResult.getRawFieldValue(this.expression); this.editor = this.bindingResult.findEditor(this.expression, null); } @@ -162,8 +162,8 @@ public class BindStatus { this.errorMessages = new String[0]; } - if (htmlEscape && this.value instanceof String valueString) { - this.value = HtmlUtils.htmlEscape(valueString); + if (htmlEscape && this.value instanceof String text) { + this.value = HtmlUtils.htmlEscape(text); } } @@ -238,8 +238,8 @@ public class BindStatus { * will get HTML-escaped. */ public String getDisplayValue() { - if (this.value instanceof String stringValue) { - return stringValue; + if (this.value instanceof String displayValue) { + return displayValue; } if (this.value != null) { return (this.htmlEscape ? diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/result/view/UrlBasedViewResolver.java b/spring-webflux/src/main/java/org/springframework/web/reactive/result/view/UrlBasedViewResolver.java index d4acf00e94..2102271034 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/result/view/UrlBasedViewResolver.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/result/view/UrlBasedViewResolver.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 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. diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/result/view/ViewResolutionResultHandler.java b/spring-webflux/src/main/java/org/springframework/web/reactive/result/view/ViewResolutionResultHandler.java index a7b99ffb66..f6389c5bc1 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/result/view/ViewResolutionResultHandler.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/result/view/ViewResolutionResultHandler.java @@ -223,7 +223,7 @@ public class ViewResolutionResultHandler extends HandlerResultHandlerSupport imp if (view == null) { view = getDefaultViewName(exchange); } - viewsMono = (view instanceof String stringView? resolveViews(stringView, locale) : + viewsMono = (view instanceof String viewName ? resolveViews(viewName, locale) : Mono.just(Collections.singletonList((View) view))); } else if (Model.class.isAssignableFrom(clazz)) { diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/MultipartIntegrationTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/MultipartIntegrationTests.java index 2287bc73b3..9a4608fba9 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/MultipartIntegrationTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/MultipartIntegrationTests.java @@ -240,7 +240,7 @@ class MultipartIntegrationTests extends AbstractRouterFunctionIntegrationTests { public Mono transferTo(ServerRequest request) { return request.body(BodyExtractors.toParts()) - .filter(part -> part instanceof FilePart) + .filter(FilePart.class::isInstance) .next() .cast(FilePart.class) .flatMap(part -> createTempFile() diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/protobuf/Msg.java b/spring-webflux/src/test/java/org/springframework/web/reactive/protobuf/Msg.java index 234b44b52c..f57c3ca4de 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/protobuf/Msg.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/protobuf/Msg.java @@ -144,8 +144,8 @@ public final class Msg extends */ public String getFoo() { Object ref = foo_; - if (ref instanceof String stringRef) { - return stringRef; + if (ref instanceof String) { + return (String) ref; } else { com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; @@ -162,9 +162,10 @@ public final class Msg extends public com.google.protobuf.ByteString getFooBytes() { Object ref = foo_; - if (ref instanceof String stringRef) { + if (ref instanceof String) { com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8(stringRef); + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); foo_ = b; return b; } else { @@ -404,8 +405,8 @@ public final class Msg extends } public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof Msg msg) { - return mergeFrom(msg); + if (other instanceof Msg) { + return mergeFrom((Msg)other); } else { super.mergeFrom(other); return this; @@ -462,13 +463,13 @@ public final class Msg extends */ public String getFoo() { Object ref = foo_; - if (!(ref instanceof String stringRef)) { + if (!(ref instanceof String)) { String s = ((com.google.protobuf.ByteString) ref) .toStringUtf8(); foo_ = s; return s; } else { - return stringRef; + return (String) ref; } } /** @@ -477,9 +478,10 @@ public final class Msg extends public com.google.protobuf.ByteString getFooBytes() { Object ref = foo_; - if (ref instanceof String stringRef) { + if (ref instanceof String) { com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8(stringRef); + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); foo_ = b; return b; } else { diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/protobuf/SecondMsg.java b/spring-webflux/src/test/java/org/springframework/web/reactive/protobuf/SecondMsg.java index 67b5a9a066..480798a0a2 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/protobuf/SecondMsg.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/protobuf/SecondMsg.java @@ -304,8 +304,8 @@ public final class SecondMsg extends } public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof SecondMsg secondMsg) { - return mergeFrom(secondMsg); + if (other instanceof SecondMsg) { + return mergeFrom((SecondMsg)other); } else { super.mergeFrom(other); return this; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/MultipartIntegrationTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/MultipartIntegrationTests.java index 9ca1ccb704..82022e0b88 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/MultipartIntegrationTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/MultipartIntegrationTests.java @@ -354,7 +354,7 @@ class MultipartIntegrationTests extends AbstractHttpHandlerIntegrationTests { } private static String partDescription(Part part) { - return part instanceof FilePart filePart? part.name() + ":" + filePart.filename() : part.name(); + return part instanceof FilePart filePart ? part.name() + ":" + filePart.filename() : part.name(); } static class FormBean { diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/function/DefaultRenderingResponseBuilder.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/function/DefaultRenderingResponseBuilder.java index 2f610350db..45f92fbc1a 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/function/DefaultRenderingResponseBuilder.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/function/DefaultRenderingResponseBuilder.java @@ -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); diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerMapping.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerMapping.java index 6e4c01a8c6..411f96f8aa 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerMapping.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerMapping.java @@ -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); } diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/support/BindStatus.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/support/BindStatus.java index f8debe853c..f84b96c21c 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/support/BindStatus.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/support/BindStatus.java @@ -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());