jeudi 27 octobre 2022

Getting method with Generic Types within signature using Reflection

I would like to invoke this method using Reflection but am a bit confused with getting the method with getDeclaredMethod(), how would this be done?

 private static <T> void registerServiceClass(final Class<T> service, final T instance) {
        Collection<Class<?>> serviceClasses = SERVICE_MAP.get(service);
        if (null == serviceClasses) {
            serviceClasses = new LinkedHashSet<>();
        }
        serviceClasses.add(instance.getClass());
        SERVICE_MAP.put(service, serviceClasses);
    }
}




Aucun commentaire:

Enregistrer un commentaire