From 08193720d93f809e988d0e37821937de3c1be8d7 Mon Sep 17 00:00:00 2001 From: isXander Date: Sun, 14 Apr 2024 23:31:43 +0100 Subject: Add util to get a flat stream of all options --- src/main/java/dev/isxander/yacl3/api/utils/OptionUtils.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main/java/dev/isxander/yacl3/api/utils/OptionUtils.java b/src/main/java/dev/isxander/yacl3/api/utils/OptionUtils.java index cf33f0f..be56f77 100644 --- a/src/main/java/dev/isxander/yacl3/api/utils/OptionUtils.java +++ b/src/main/java/dev/isxander/yacl3/api/utils/OptionUtils.java @@ -4,8 +4,17 @@ import dev.isxander.yacl3.api.*; import java.util.function.Consumer; import java.util.function.Function; +import java.util.stream.Stream; public class OptionUtils { + public static Stream> getFlatOptions(YetAnotherConfigLib yacl) { + return yacl.categories().stream() + .flatMap(category -> category.groups().stream()) + .flatMap(group -> group instanceof ListOption list + ? Stream.of(list) + : group.options().stream()); + } + /** * Consumes all options, ignoring groups and categories. * When consumer returns true, this function stops iterating. -- cgit