Skip to content

Commit

Permalink
[refactor] Use Java 17 switch expression as requested by @reinhapa in…
Browse files Browse the repository at this point in the history
… code-review
  • Loading branch information
adamretter committed Apr 10, 2023
1 parent b237a56 commit 216d514
Showing 1 changed file with 10 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,23 +89,15 @@ public static NodeProxy create(final NodeProxy nodeProxy) {
}

private static Class<? extends Node> getNodeClass(final NodeProxy nodeProxy) {
switch (nodeProxy.getType()) {
case Type.ELEMENT:
return Element.class;
case Type.ATTRIBUTE:
return Attr.class;
case Type.TEXT:
return Text.class;
case Type.PROCESSING_INSTRUCTION:
return ProcessingInstruction.class;
case Type.COMMENT:
return Comment.class;
case Type.DOCUMENT:
return Document.class;
case Type.CDATA_SECTION:
return CDATASection.class;
default:
return Node.class;
}
return switch (nodeProxy.getType()) {
case Type.ELEMENT -> Element.class;
case Type.ATTRIBUTE -> Attr.class;
case Type.TEXT -> Text.class;
case Type.PROCESSING_INSTRUCTION -> ProcessingInstruction.class;
case Type.COMMENT -> Comment.class;
case Type.DOCUMENT -> Document.class;
case Type.CDATA_SECTION -> CDATASection.class;
default -> Node.class;
};
}
}

0 comments on commit 216d514

Please sign in to comment.