Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up function signatures and approach for #298 #310

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,14 @@ private static ISequence<IStringItem> execute(
* @param items
* the items to join in string form
* @param separator
* the optional separator to use between joined items
* the optional separator to use between joined items
* @return the atomized result
*/
@NonNull
public static IStringItem fnStringJoin(@NonNull List<? extends IAnyAtomicItem> items, IStringItem separator) {
return IStringItem.valueOf(stringJoin(ObjectUtils.notNull(items.stream()), separator == null ? "" : separator.asString()));
return IStringItem
.valueOf(stringJoin(items.stream().map(item -> item == null ? "" : IStringItem.cast(item).asString()),
separator == null ? "" : separator.asString()));
}

/**
Expand All @@ -113,13 +115,11 @@ public static IStringItem fnStringJoin(@NonNull List<? extends IAnyAtomicItem> i
* @param items
* the items to join in string form
* @param separator
* the optional separator to use between joined items
* the optional separator to use between joined items
* @return the atomized result
*/
@NonNull
private static String stringJoin(@NonNull Stream<? extends IAnyAtomicItem> items, String separator) {
return ObjectUtils.notNull(items
.map(item -> item == null ? "" : IStringItem.cast(item).asString())
.collect(Collectors.joining(separator)));
private static String stringJoin(@NonNull Stream<String> items, String separator) {
return ObjectUtils.notNull(items.collect(Collectors.joining(separator)));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ private static Stream<Arguments> provideValues() { // NOPMD - false positive
string("123456789"),
"string-join(1 to 9)"),
Arguments.of(
string("123456789"),
"string-join(1 to 9, '')"),
string("123456789"),
"string-join(1 to 9, '')"),
Arguments.of(
string("123456789"),
"string-join(1 to 9, ())"),
string("123456789"),
"string-join(1 to 9, ())"),
Arguments.of(
string("Now is the time ..."),
"string-join(('Now', 'is', 'the', 'time', '...'), ' ')"),
Expand All @@ -42,7 +42,10 @@ private static Stream<Arguments> provideValues() { // NOPMD - false positive
"string-join((), 'separator')"),
Arguments.of(
string("1, 2, 3, 4, 5"),
"string-join(1 to 5, ', ')")
"string-join(1 to 5, ', ')"),
Arguments.of(
string("123"),
"string-join((1, '', 2, 3))")
// Arguments.of(
// string("xml:id=\"xyz\""),
// "let $doc := <doc><chap><section xml:id=\"xyz\"/></chap></doc>\n"
Expand Down
Loading