### Question:
FactoryMethod { static FactoryMethod find(final Class<?> type, final Object[] factories) { for (final Object factory : factories) { for (final Method method : factory.getClass().getMethods()) { if (method.isSynthetic() || method.isAnnotationPresent(Deprecated.class)) { continue; } final String name = method.getName(); if (!name.startsWith("create")) { continue; } if (!type.isAssignableFrom(method.getReturnType())) { continue; } Type[] types = method.getGenericParameterTypes(); if (types.length == 0) { continue; } final Type mapType = types[0]; if (mapType != Map.class) { if (!(mapType instanceof ParameterizedType)) { continue; } types = ((ParameterizedType) mapType).getActualTypeArguments(); if (types.length != 2 || !bounds(types[0]).isAssignableFrom(String.class) || !bounds(types[1]).isAssignableFrom(Object.class)) { continue; } return new FactoryMethod(method, factory); } } } return null; } private  FactoryMethod(final Method method, final Object factory); @Override boolean equals(final Object other); @Override int hashCode();  }### Answer:
@Test public void testFind() { final Object[] crsFactory = Collections.singleton(DefaultFactories.forBuildin(CRSFactory.class)).toArray(); FactoryMethod fm; fm = FactoryMethod.find(Citation.class, crsFactory); assertNull("The CRS factory can not create Citation objects.", fm); fm = FactoryMethod.find(VerticalCRS.class, crsFactory); assertNotNull("The CRSFactory.createVerticalCRS(Map, ...) method should have been found.", fm); assertEquals(fm, FactoryMethod.find(VerticalCRS.class, crsFactory)); }