|
29 | 29 | import org.exist.numbering.NodeId;
|
30 | 30 | import org.exist.xmldb.XmldbURI;
|
31 | 31 | import org.exist.xquery.Cardinality;
|
| 32 | +import org.exist.xquery.Expression; |
32 | 33 | import org.exist.xquery.XPathException;
|
33 | 34 | import org.exist.xquery.XQueryContext;
|
34 | 35 |
|
@@ -362,23 +363,23 @@ default int getItemCount() {
|
362 | 363 | void destroy(final XQueryContext context, @Nullable final Sequence contextSequence);
|
363 | 364 |
|
364 | 365 | static Sequence of(@Nullable final XmldbURI... uris) throws XPathException {
|
365 |
| - if (uris == null || uris.length == 0 || (uris.length == 1 && uris[0] == null)) { |
366 |
| - return Sequence.EMPTY_SEQUENCE; |
367 |
| - } |
368 |
| - return ValueSequence.of(FunctionE.<XmldbURI, Item, XPathException>lift(thing -> new StringValue(thing.toString())), uris); |
| 366 | + final FunctionE liftedMapper = FunctionE.<XmldbURI, Item, XPathException>lift( |
| 367 | + thing -> new StringValue(thing.toString())); |
| 368 | + return of(liftedMapper, uris); |
369 | 369 | }
|
370 | 370 |
|
371 | 371 | static Sequence of(@Nullable final Integer... ints) throws XPathException {
|
372 |
| - if (ints == null || ints.length == 0 || (ints.length == 1 && ints[0] == null)) { |
373 |
| - return Sequence.EMPTY_SEQUENCE; |
374 |
| - } |
375 |
| - return ValueSequence.of(thing -> new IntegerValue(thing, Type.INT), ints); |
| 372 | + return of(thing -> new IntegerValue(thing, Type.INT), ints); |
376 | 373 | }
|
377 | 374 |
|
378 | 375 | static Sequence of(@Nullable final BigInteger... bigIntegers) throws XPathException {
|
379 |
| - if (bigIntegers == null || bigIntegers.length == 0 || (bigIntegers.length == 1 && bigIntegers[0] == null)) { |
| 376 | + return of(thing -> new IntegerValue(thing.toString(), Type.INTEGER), bigIntegers); |
| 377 | + } |
| 378 | + |
| 379 | + static <T> Sequence of(final FunctionE<T, Item, XPathException> mapper, @Nullable final T... things) throws XPathException { |
| 380 | + if (things == null || things.length == 0 || (things.length == 1 && things[0] == null)) { |
380 | 381 | return Sequence.EMPTY_SEQUENCE;
|
381 | 382 | }
|
382 |
| - return ValueSequence.of(thing -> new IntegerValue(thing.toString(), Type.INTEGER), bigIntegers); |
| 383 | + return ValueSequence.of(mapper, things); |
383 | 384 | }
|
384 | 385 | }
|
0 commit comments