From ecaea8c0b09431eabddd323a87fce59bba6f0238 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Wed, 7 Dec 2011 16:03:38 +0100 Subject: [PATCH] Extend Options to include enum options. --- .../java/net/pterodactylus/sone/core/Options.java | 36 ++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/main/java/net/pterodactylus/sone/core/Options.java b/src/main/java/net/pterodactylus/sone/core/Options.java index 1bdf21f..f280aae 100644 --- a/src/main/java/net/pterodactylus/sone/core/Options.java +++ b/src/main/java/net/pterodactylus/sone/core/Options.java @@ -226,6 +226,9 @@ public class Options { /** Holds all {@link String} {@link Option}s. */ private final Map> stringOptions = Collections.synchronizedMap(new HashMap>()); + /** Holds all {@link Enum} {@link Option}s. */ + private final Map>> enumOptions = Collections.synchronizedMap(new HashMap>>()); + /** * Adds a boolean option. * @@ -304,4 +307,37 @@ public class Options { return stringOptions.get(name); } + /** + * Adds an {@link Enum} {@link Option}. + * + * @param name + * The name of the option + * @param enumOption + * The option + * @return The given option + */ + public > Option addEnumOption(String name, Option enumOption) { + enumOptions.put(name, enumOption); + return enumOption; + } + + /** + * Returns a {@link Enum} {@link Option}. As the type can probably not be + * interred correctly you could help the compiler by calling this method + * like this: + *

+ * + *

+	 * options.<SomeEnum> getEnumOption("SomeEnumOption").get();
+	 * 
+ * + * @param name + * The name of the option + * @return The enum option, or {@code null} if there is no enum option with + * the given name + */ + public > Option getEnumOption(String name) { + return (Option) enumOptions.get(name); + } + } -- 2.7.4