Add String options.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sat, 15 Jan 2011 20:10:35 +0000 (21:10 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sat, 15 Jan 2011 20:25:56 +0000 (21:25 +0100)
src/main/java/net/pterodactylus/sone/core/Options.java

index f77c085..b7ece81 100644 (file)
@@ -161,6 +161,9 @@ public class Options {
        /** Holds all {@link Integer} {@link Option}s. */
        private final Map<String, Option<Integer>> integerOptions = Collections.synchronizedMap(new HashMap<String, Option<Integer>>());
 
+       /** Holds all {@link String} {@link Option}s. */
+       private final Map<String, Option<String>> stringOptions = Collections.synchronizedMap(new HashMap<String, Option<String>>());
+
        /**
         * Adds a boolean option.
         *
@@ -213,4 +216,30 @@ public class Options {
                return integerOptions.get(name);
        }
 
+       /**
+        * Adds a {@link String} {@link Option}.
+        *
+        * @param name
+        *            The name of the option
+        * @param stringOption
+        *            The option
+        * @return The given option
+        */
+       public Option<String> addStringOption(String name, Option<String> stringOption) {
+               stringOptions.put(name, stringOption);
+               return stringOption;
+       }
+
+       /**
+        * Returns a {@link String} {@link Option}.
+        *
+        * @param name
+        *            The name of the string option to get
+        * @return The string option, or {@code null} if there is no option with the
+        *         given name
+        */
+       public Option<String> getStringOption(String name) {
+               return stringOptions.get(name);
+       }
+
 }