From 241671c0aaab87c17029ab87ccff859bf7ef19e9 Mon Sep 17 00:00:00 2001 From: Marc Baloup Date: Sat, 24 Mar 2018 19:10:44 +0100 Subject: [PATCH] Little improvement of TabProposal --- .../fr/pandacube/java/util/commands/TabProposal.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main/java/fr/pandacube/java/util/commands/TabProposal.java b/src/main/java/fr/pandacube/java/util/commands/TabProposal.java index bcb19ba..a728c2d 100644 --- a/src/main/java/fr/pandacube/java/util/commands/TabProposal.java +++ b/src/main/java/fr/pandacube/java/util/commands/TabProposal.java @@ -23,6 +23,15 @@ public interface TabProposal { public static TabProposal empty() { return Collections::emptyList; } + + public static > TabProposal fromEnum(Class enumClass) { + return fromEnumValues(enumClass.getEnumConstants()); + } + + @SafeVarargs + public static > TabProposal fromEnumValues(E... enumValues) { + return () -> Arrays.stream(enumValues).map(Enum::name).collect(Collectors.toList()); + } public static TabProposal fromCollection(Collection proposals) { return () -> proposals;