Skip to content

Commit 3ecf900

Browse files
committed
[refactor] Java14 - enhanced switch
1 parent 143732d commit 3ecf900

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

exist-core/src/main/java/org/exist/stax/StaXUtil.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,19 @@
2929
public class StaXUtil {
3030

3131
public static int streamType2Type(final int type) {
32-
int xpathType = switch (type) {
32+
return switch (type) {
3333
case XMLStreamConstants.START_ELEMENT -> Type.ELEMENT;
3434
case XMLStreamConstants.PROCESSING_INSTRUCTION -> Type.PROCESSING_INSTRUCTION;
35-
case XMLStreamConstants.CHARACTERS -> Type.TEXT;
35+
case XMLStreamConstants.CHARACTERS, XMLStreamConstants.CDATA -> Type.TEXT;
3636
case XMLStreamConstants.COMMENT -> Type.COMMENT;
3737
case XMLStreamConstants.START_DOCUMENT -> Type.DOCUMENT;
3838
case XMLStreamConstants.ATTRIBUTE -> Type.ATTRIBUTE;
39-
case XMLStreamConstants.CDATA -> Type.TEXT;
4039
default -> Type.UNTYPED;
4140
};
42-
return xpathType;
4341
}
4442

4543
public static short streamType2DOM(final int type) {
46-
short domType = switch (type) {
44+
return switch (type) {
4745
case XMLStreamConstants.START_ELEMENT -> Node.ELEMENT_NODE;
4846
case XMLStreamConstants.PROCESSING_INSTRUCTION -> Node.PROCESSING_INSTRUCTION_NODE;
4947
case XMLStreamConstants.CHARACTERS -> Node.TEXT_NODE;
@@ -56,6 +54,5 @@ public static short streamType2DOM(final int type) {
5654
case XMLStreamConstants.ENTITY_DECLARATION -> Node.ENTITY_NODE;
5755
default -> -1;
5856
};
59-
return domType;
6057
}
6158
}

0 commit comments

Comments
 (0)