Skip to content

Commit 826ef2d

Browse files
joewizclaude
andcommitted
[refactor] Address review feedback from @reinhapa
Convert version if-else chain in XQueryTree.g to switch-as-expression. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent dadb5e4 commit 826ef2d

1 file changed

Lines changed: 7 additions & 11 deletions

File tree

  • exist-core/src/main/antlr/org/exist/xquery/parser

exist-core/src/main/antlr/org/exist/xquery/parser/XQueryTree.g

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -267,17 +267,13 @@ throws PermissionDeniedException, EXistException, XPathException
267267
v:VERSION_DECL
268268
{
269269
final String version = v.getText();
270-
if (version.equals("4.0")) {
271-
context.setXQueryVersion(40);
272-
} else if (version.equals("3.1")) {
273-
context.setXQueryVersion(31);
274-
} else if (version.equals("3.0")) {
275-
context.setXQueryVersion(30);
276-
} else if (version.equals("1.0")) {
277-
context.setXQueryVersion(10);
278-
} else {
279-
throw new XPathException(v, ErrorCodes.XQST0031, "Wrong XQuery version: require 1.0, 3.0, 3.1, or 4.0");
280-
}
270+
context.setXQueryVersion(switch (version) {
271+
case "4.0" -> 40;
272+
case "3.1" -> 31;
273+
case "3.0" -> 30;
274+
case "1.0" -> 10;
275+
default -> throw new XPathException(v, ErrorCodes.XQST0031, "Wrong XQuery version: require 1.0, 3.0, 3.1, or 4.0");
276+
});
281277
}
282278
( enc:STRING_LITERAL )?
283279
{

0 commit comments

Comments
 (0)