diff --git a/li.strolch.agent/src/main/java/li/strolch/search/RootElementSearchResult.java b/li.strolch.agent/src/main/java/li/strolch/search/RootElementSearchResult.java index 99b1b1439..90f2020f8 100644 --- a/li.strolch.agent/src/main/java/li/strolch/search/RootElementSearchResult.java +++ b/li.strolch.agent/src/main/java/li/strolch/search/RootElementSearchResult.java @@ -103,19 +103,6 @@ public class RootElementSearchResult extends Searc return this; } - /** - * Returns the single element in the stream, or throws an {@link IllegalStateException} if the stream does not - * contain 1 and only 1 element - * - * @return the single element in the stream - * - * @throws IllegalStateException - * if not 1 and only 1 element is in the stream - */ - public T toSingleton(Supplier errorMsgSupplier) throws IllegalStateException { - return this.stream.collect(CollectionsHelper.singletonCollector(errorMsgSupplier)); - } - /** * Transforms this search result to be a search result returning elements with the given visitor * diff --git a/li.strolch.agent/src/main/java/li/strolch/search/SearchResult.java b/li.strolch.agent/src/main/java/li/strolch/search/SearchResult.java index 511e933c6..47e07cb8b 100644 --- a/li.strolch.agent/src/main/java/li/strolch/search/SearchResult.java +++ b/li.strolch.agent/src/main/java/li/strolch/search/SearchResult.java @@ -7,9 +7,11 @@ import java.util.Set; import java.util.function.Consumer; import java.util.function.Function; import java.util.function.Predicate; +import java.util.function.Supplier; import java.util.stream.Collectors; import java.util.stream.Stream; +import li.strolch.utils.collections.CollectionsHelper; import li.strolch.utils.collections.Paging; /** @@ -133,6 +135,19 @@ public class SearchResult { return Paging.asPage(this.stream.collect(Collectors.toList()), offset, limit); } + /** + * Returns the single element in the stream, or throws an {@link IllegalStateException} if the stream does not + * contain 1 and only 1 element + * + * @return the single element in the stream + * + * @throws IllegalStateException + * if not 1 and only 1 element is in the stream + */ + public T toSingleton(Supplier errorMsgSupplier) throws IllegalStateException { + return this.stream.collect(CollectionsHelper.singletonCollector(errorMsgSupplier)); + } + /** * Performs a simple for each on every element *