Added Registry.get() that does not need a class argument.
Change-Id: I3e8b0e3cc14eda914e0b1b201e6ddf67a9e3462e
Issue-ID: POLICY-1542
Signed-off-by: Jim Hahn <jrh3@att.com>
return (instance.name2object.remove(name) != null);
}
+ /**
+ * Gets the object by the given name.
+ *
+ * @param name name of the object to get
+ * @return the object
+ * @throws IllegalArgumentException if no object is registered by the given name
+ */
+ @SuppressWarnings("unchecked")
+ public static <T> T get(String name) {
+ Object obj = instance.name2object.get(name);
+ if (obj == null) {
+ throw new IllegalArgumentException("not registered: " + name);
+ }
+
+ return (T) obj;
+ }
+
/**
* Gets the object by the given name.
*