PropertyConverterManager { private Method getFactoryMethod(Class<?> type, String... methodNames) { Method m; for (String name : methodNames) { try { m = type.getDeclaredMethod(name, String.class); return m; } catch (NoSuchMethodException | RuntimeException e) { } try { m = type.getDeclaredMethod(name, CharSequence.class); return m; } catch (NoSuchMethodException | RuntimeException e) { LOG.finest("No such factory method found on type: " + type.getName() + ", methodName: " + name); } } return null; } PropertyConverterManager(ServiceContext serviceContext);  PropertyConverterManager(ServiceContext serviceContext, boolean init); @SuppressWarnings("unchecked") void register(TypeLiteral<T> targetType, PropertyConverter<T> converter); boolean isTargetTypeSupported(TypeLiteral<?> targetType); Map<TypeLiteral<?>, List<PropertyConverter<?>>> getPropertyConverters(); List<PropertyConverter<T>> getPropertyConverters(TypeLiteral<T> targetType); @Override boolean equals(Object o); @Override int hashCode();  }
@Test public void testGetFactoryMethod() throws Exception { ServiceContext serviceContext = ServiceContextManager.getServiceContext(getClass().getClassLoader()); PropertyConverterManager manager = new PropertyConverterManager(serviceContext, false); Method getFactoryMethod = PropertyConverterManager.class.getDeclaredMethod("getFactoryMethod", new Class[]{Class.class, String[].class}); getFactoryMethod.setAccessible(true); Method foundMethod = (Method) getFactoryMethod.invoke(manager, MyType.class, new String[]{"instanceOf"}); assertThat(foundMethod.getName()).isEqualTo("instanceOf"); Method staticOf = (Method) getFactoryMethod.invoke(manager, MyType.class, new String[]{"of"}); assertThat(staticOf.getName()).isEqualTo("of"); Method notFoundMethod = (Method) getFactoryMethod.invoke(manager, MyType.class, new String[]{"missingMethod"}); assertThat(notFoundMethod).isNull(); Method wrongSignature = (Method) getFactoryMethod.invoke(manager, MyType.class, new String[]{"getValue"}); assertThat(wrongSignature).isNull(); }