Skip to content

Commit fe59d2a

Browse files
committed
[refactor] replace ArrayUtils.contains with Set.contains in FunBaseURI
1 parent d419c8e commit fe59d2a

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

exist-core/src/main/java/org/exist/xquery/functions/fn/FunBaseURI.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@
2121
*/
2222
package org.exist.xquery.functions.fn;
2323

24-
import org.apache.commons.lang3.ArrayUtils;
2524
import org.apache.commons.lang3.StringUtils;
2625
import org.exist.xquery.*;
2726
import org.exist.xquery.value.*;
2827
import org.w3c.dom.Node;
2928

3029
import java.net.URI;
3130
import java.net.URISyntaxException;
31+
import java.util.Set;
3232

3333
import static org.exist.xquery.FunctionDSL.optParam;
3434
import static org.exist.xquery.FunctionDSL.returnsOpt;
@@ -67,6 +67,12 @@ public class FunBaseURI extends BasicFunction {
6767
FS_PARAM_NODE
6868
);
6969

70+
// Namespace node does not exist in xquery, hence left out of array.
71+
private static final Set<Short> CANDIDATE_NODE_TYPES = Set.of(
72+
Node.DOCUMENT_NODE, Node.ELEMENT_NODE, Node.ATTRIBUTE_NODE, Node.TEXT_NODE,
73+
Node.COMMENT_NODE, Node.PROCESSING_INSTRUCTION_NODE
74+
);
75+
7076
public FunBaseURI(XQueryContext context, FunctionSignature signature) {
7177
super(context, signature);
7278
}
@@ -119,13 +125,8 @@ public Sequence eval(Sequence[] args, Sequence contextSequence) throws XPathExce
119125
final Node node = nodeValue.getNode();
120126
final short type = node.getNodeType();
121127

122-
// Namespace node does not exist in xquery, hence left out of array.
123-
final short[] quickStops = {Node.ELEMENT_NODE, Node.ATTRIBUTE_NODE,
124-
Node.PROCESSING_INSTRUCTION_NODE, Node.COMMENT_NODE, Node.TEXT_NODE,
125-
Node.DOCUMENT_NODE};
126-
127128
// Quick escape
128-
if (!ArrayUtils.contains(quickStops, type)) {
129+
if (!CANDIDATE_NODE_TYPES.contains(type)) {
129130
return Sequence.EMPTY_SEQUENCE;
130131
}
131132

0 commit comments

Comments
 (0)