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

@@ -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 "";
}
}
}