From 76fb04596ee371e7ee2eedac0fa4db9268668000 Mon Sep 17 00:00:00 2001 From: Adam Retter Date: Wed, 14 Jun 2023 15:37:50 +0100 Subject: [PATCH] [refactor] Address further code-review from @reinhapa --- .../src/main/java/org/exist/xquery/BindingExpression.java | 4 ++-- exist-core/src/main/java/org/exist/xquery/CountClause.java | 6 +++--- .../src/main/java/org/exist/xquery/GroupByClause.java | 4 ++-- .../src/main/java/org/exist/xquery/OrderByClause.java | 4 ++-- exist-core/src/main/java/org/exist/xquery/WhereClause.java | 4 ++-- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/exist-core/src/main/java/org/exist/xquery/BindingExpression.java b/exist-core/src/main/java/org/exist/xquery/BindingExpression.java index 521456d36d1..57ea725e6c3 100644 --- a/exist-core/src/main/java/org/exist/xquery/BindingExpression.java +++ b/exist-core/src/main/java/org/exist/xquery/BindingExpression.java @@ -83,8 +83,8 @@ public void analyze(final AnalyzeContextInfo contextInfo) throws XPathException @Override public Sequence postEval(Sequence seq) throws XPathException { - if (returnExpr instanceof FLWORClause) { - seq = ((FLWORClause)returnExpr).postEval(seq); + if (returnExpr instanceof FLWORClause flworClause) { + seq = flworClause.postEval(seq); } return super.postEval(seq); } diff --git a/exist-core/src/main/java/org/exist/xquery/CountClause.java b/exist-core/src/main/java/org/exist/xquery/CountClause.java index 7a25ccb8708..69494fb2af9 100644 --- a/exist-core/src/main/java/org/exist/xquery/CountClause.java +++ b/exist-core/src/main/java/org/exist/xquery/CountClause.java @@ -111,8 +111,8 @@ private boolean hasPreviousOrderByDescending() { case ORDERBY -> { return isDescending(((OrderByClause) prev).getOrderSpecs()); } + default -> prev = prev.getPreviousClause(); } - prev = prev.getPreviousClause(); } return true; } @@ -183,8 +183,8 @@ public Sequence eval(final Sequence contextSequence, final Item contextItem) thr @Override public Sequence postEval(Sequence seq) throws XPathException { - if (returnExpr instanceof FLWORClause) { - seq = ((FLWORClause)returnExpr).postEval(seq); + if (returnExpr instanceof FLWORClause flworClause) { + seq = flworClause.postEval(seq); } return super.postEval(seq); } diff --git a/exist-core/src/main/java/org/exist/xquery/GroupByClause.java b/exist-core/src/main/java/org/exist/xquery/GroupByClause.java index 82e31951818..5db24ea0293 100644 --- a/exist-core/src/main/java/org/exist/xquery/GroupByClause.java +++ b/exist-core/src/main/java/org/exist/xquery/GroupByClause.java @@ -172,8 +172,8 @@ public Sequence postEval(final Sequence seq) throws XPathException { context.popLocalVariables(mark, result); } - if (returnExpr instanceof FLWORClause) { - result = ((FLWORClause) returnExpr).postEval(result); + if (returnExpr instanceof FLWORClause flworClause) { + result = flworClause.postEval(result); } result = super.postEval(result); return result; diff --git a/exist-core/src/main/java/org/exist/xquery/OrderByClause.java b/exist-core/src/main/java/org/exist/xquery/OrderByClause.java index 11f8bd941b4..84bd07c5a1e 100644 --- a/exist-core/src/main/java/org/exist/xquery/OrderByClause.java +++ b/exist-core/src/main/java/org/exist/xquery/OrderByClause.java @@ -95,8 +95,8 @@ public Sequence postEval(Sequence seq) throws XPathException { orderedResult.sort(); Sequence result = orderedResult; - if (getReturnExpression() instanceof FLWORClause) { - result = ((FLWORClause) getReturnExpression()).postEval(result); + if (getReturnExpression() instanceof FLWORClause flworClause) { + result = flworClause.postEval(result); } return super.postEval(result); } diff --git a/exist-core/src/main/java/org/exist/xquery/WhereClause.java b/exist-core/src/main/java/org/exist/xquery/WhereClause.java index ecb9d5aeaa0..7b453c28a31 100644 --- a/exist-core/src/main/java/org/exist/xquery/WhereClause.java +++ b/exist-core/src/main/java/org/exist/xquery/WhereClause.java @@ -133,8 +133,8 @@ public Sequence eval(Sequence contextSequence, Item contextItem) throws XPathExc @Override public Sequence postEval(Sequence seq) throws XPathException { fastTrack = false; - if (returnExpr instanceof FLWORClause) { - seq = ((FLWORClause) returnExpr).postEval(seq); + if (returnExpr instanceof FLWORClause flworClause) { + seq = flworClause.postEval(seq); } return super.postEval(seq); }