Polishing.

All of these instanceof checks can also take advantage of Java 17's pattern matching instanceof operator.

Related: #1326.
This commit is contained in:
Greg L. Turnquist
2023-02-06 16:20:11 -05:00
parent a7a2726194
commit 1fa1365817
5 changed files with 7 additions and 12 deletions

View File

@@ -156,8 +156,7 @@ public final class MethodEndpoint {
if (this == o) {
return true;
}
if (o instanceof MethodEndpoint) {
MethodEndpoint other = (MethodEndpoint) o;
if (o instanceof MethodEndpoint other) {
return this.bean.equals(other.bean) && this.method.equals(other.method);
}
return false;

View File

@@ -127,8 +127,7 @@ public class XPathParamAnnotationMethodEndpointAdapter extends AbstractMethodEnd
Element payloadElement = getRootElement(messageContext.getRequest().getPayloadSource());
Object[] args = getMethodArguments(payloadElement, methodEndpoint.getMethod());
Object result = methodEndpoint.invoke(args);
if (result instanceof Source) {
Source responseSource = (Source) result;
if (result instanceof Source responseSource) {
WebServiceMessage response = messageContext.getResponse();
transform(responseSource, response.getPayloadResult());
}

View File

@@ -90,8 +90,7 @@ public final class EndpointReference implements Serializable {
if (this == o) {
return true;
}
if (o instanceof EndpointReference) {
EndpointReference other = (EndpointReference) o;
if (o instanceof EndpointReference other) {
return address.equals(other.address);
}
return false;

View File

@@ -852,8 +852,7 @@ public class Wss4jSecurityInterceptor extends AbstractWsSecurityInterceptor impl
if (!CollectionUtils.isEmpty(results)) {
WSSecurityEngineResult actionResult = results.get(0);
Principal principal = (Principal) actionResult.get(WSSecurityEngineResult.TAG_PRINCIPAL);
if (principal instanceof WSUsernameTokenPrincipalImpl) {
WSUsernameTokenPrincipalImpl usernameTokenPrincipal = (WSUsernameTokenPrincipalImpl) principal;
if (principal instanceof WSUsernameTokenPrincipalImpl usernameTokenPrincipal) {
UsernameTokenPrincipalCallback callback = new UsernameTokenPrincipalCallback(usernameTokenPrincipal);
try {
validationCallbackHandler.handle(new Callback[] { callback });

View File

@@ -62,10 +62,7 @@ public class QNameEditor extends PropertyEditorSupport {
@Override
public String getAsText() {
Object value = getValue();
if (!(value instanceof QName)) {
return "";
} else {
QName qName = (QName) value;
if (value instanceof QName qName) {
String prefix = qName.getPrefix();
if (StringUtils.hasLength(qName.getNamespaceURI()) && StringUtils.hasLength(prefix)) {
return "{" + qName.getNamespaceURI() + "}" + prefix + ":" + qName.getLocalPart();
@@ -74,6 +71,8 @@ public class QNameEditor extends PropertyEditorSupport {
} else {
return qName.getLocalPart();
}
} else {
return "";
}
}
}