From e628e6b1dc30649da1c1a3b31d66ee19665c3c25 Mon Sep 17 00:00:00 2001 From: Mateusz Warowny Date: Wed, 22 Mar 2023 12:50:47 +0100 Subject: [PATCH] JAL-4152 Make return type of getInstance a generic type --- src/jalview/bin/ApplicationSingletonProvider.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/jalview/bin/ApplicationSingletonProvider.java b/src/jalview/bin/ApplicationSingletonProvider.java index 450809a..1367fab 100644 --- a/src/jalview/bin/ApplicationSingletonProvider.java +++ b/src/jalview/bin/ApplicationSingletonProvider.java @@ -106,7 +106,8 @@ public class ApplicationSingletonProvider * @param c * @return */ - public static ApplicationSingletonI getInstance(Class c) + @SuppressWarnings("unchecked") + public static T getInstance(Class c) { Map, ApplicationSingletonI> map = getContextMap(); if (map.containsKey(c)) @@ -114,17 +115,16 @@ public class ApplicationSingletonProvider /* * 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 con = c - .getDeclaredConstructor(); + Constructor con = c.getDeclaredConstructor(); con.setAccessible(true); o = con.newInstance(); } catch (IllegalAccessException | InstantiationException -- 1.7.10.2