### Question:
FactoryMethod { Object create(Map<String,?> properties) throws FactoryException { if (method == null) { return null; } final Class<?>[] types = method.getParameterTypes(); final Object[] parameters = new Object[types.length]; if (types.length > 1) { final Map<String,Object> reduced = new LinkedHashMap<>(properties); properties = reduced; for (int i=1; i<types.length; i++) { final Class<?> expected = types[i]; for (final Iterator<Object> it=reduced.values().iterator(); it.hasNext();) { final Object value = it.next(); if (expected.isInstance(value)) { parameters[i] = value; it.remove(); break; } } } } parameters[0] = properties; try { return method.invoke(factory, parameters); } catch (IllegalAccessException e) { throw new AssertionError(e); } catch (InvocationTargetException e) { final Throwable cause = e.getCause(); if (cause instanceof FactoryException) { throw (FactoryException) cause; } throw new FactoryException(cause.getLocalizedMessage(), cause); } } private  FactoryMethod(final Method method, final Object factory); @Override boolean equals(final Object other); @Override int hashCode();  }### Answer:
@Test public void testCreate() throws FactoryException { final Object[] crsFactory =Collections.singleton(DefaultFactories.forBuildin(CRSFactory.class)).toArray(); final FactoryMethod fm = FactoryMethod.find(VerticalCRS.class, crsFactory); final Map<String,Object> properties = new HashMap<>(); assertNull(properties.put("datum", CommonCRS.Vertical.MEAN_SEA_LEVEL.datum())); assertNull(properties.put("cs", CommonCRS.Vertical.MEAN_SEA_LEVEL.crs().getCoordinateSystem())); assertNull(properties.put("name", "Geoidal height")); final Object crs = fm.create(properties); assertTrue(crs instanceof VerticalCRS); assertEquals(new DefaultVerticalCRS(singletonMap(NAME_KEY, "Geoidal height"), CommonCRS.Vertical.MEAN_SEA_LEVEL.datum(), CommonCRS.Vertical.MEAN_SEA_LEVEL.crs().getCoordinateSystem()), crs); }