* @param c
* @return
*/
- public static ApplicationSingletonI getInstance(Class<? extends ApplicationSingletonI> c)
+ @SuppressWarnings("unchecked")
+ public static <T extends ApplicationSingletonI> T getInstance(Class<T> c)
{
Map<Class<? extends ApplicationSingletonI>, ApplicationSingletonI> map = getContextMap();
if (map.containsKey(c))
/*
* singleton already created _or_ creation failed (null value stored)
*/
- return map.get(c);
+ return (T) map.get(c);
}
/*
* create and save the singleton
*/
- ApplicationSingletonI o = map.get(c);
+ T o = null;
try
{
- Constructor<? extends ApplicationSingletonI> con = c
- .getDeclaredConstructor();
+ Constructor<T> con = c.getDeclaredConstructor();
con.setAccessible(true);
o = con.newInstance();
} catch (IllegalAccessException | InstantiationException