diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..fd1b092 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/.idea/ +*.iml \ No newline at end of file diff --git a/src/main/java/com/jagrosh/jagtag/Parser.java b/src/main/java/com/jagrosh/jagtag/Parser.java index fae3ceb..e43555b 100644 --- a/src/main/java/com/jagrosh/jagtag/Parser.java +++ b/src/main/java/com/jagrosh/jagtag/Parser.java @@ -76,6 +76,30 @@ public synchronized Parser clear() environment.clear(); return this; } + + /** + * Gets an item from the environment, can be used to retrieve objects after parsing + * + * @param key - the name of the object to retrieve + * @return a possibly null object with the specified key + * @see #getOrDefault(String, Object) + */ + public synchronized T get(String key) + { + return environment.get(key); + } + + /** + * Gets an item from the environment, can be used to retrieve objects after parsing + * + * @param key - the name of the object to retrieve + * @param defaultValue - the default value to return in case no object was found for the specified key + * @return the object stored for the key or the default value + */ + public synchronized T getOrDefault(String key, T defaultValue) + { + return environment.getOrDefault(key, defaultValue); + } /** * Parses a String of JagTag code, utilizing the object that have been added