BuilderUtils { public static Object convertToParameterValue(Object object) { if (object == null || object instanceof String || object instanceof String[] || object instanceof Boolean) { return object; } else if (object instanceof Integer) { return object; } else if (object instanceof Long) { return ((Long) object).intValue(); } else if (object instanceof Float) { return object; } else if (object instanceof Double) { return ((Double) object).floatValue(); } else if (object instanceof Object[] || object instanceof Collection) { return convertToParameterValues(object); } else { return object.toString(); } } private  BuilderUtils(); static String getComponentName(Collection<String> existingNames, String name); static Class<S> getClassFromString(
      String className, String... defaultPackage); static Object convertToParameterValue(Object object); static Object convertToParameterValues(Object object); static Object[] mergeAndExtractParams(
      Map<String, ? extends Object> globalConfig,
      Map<String, ? extends Object> localParams,
      Collection<String> ignoreParams,
      Map<String, ExternalResourceDescription> resources); static Object[] extractParams(
      Map<String, ? extends Object> config,
      Collection<String> ignoreParams,
      Map<String, ExternalResourceDescription> resources); static String getClassNameFromConfig(Object config); static Map<String, Object> getParamsFromConfig(Object config); static Object[] convertToStringArray(Object[] params); static Map<String, Object> flattenConfig(String key, Map<String, Object> config);  }
@Test public void testConvertToParameterValue() { Object n = null; assertEquals(null, convertToParameterValue(n)); Object s = "Hello World"; assertEquals("Hello World", convertToParameterValue(s)); Object ss = new String[2]; assertTrue(convertToParameterValue(ss) instanceof String[]); Object b = true; assertEquals(true, convertToParameterValue(b)); b = false; assertEquals(false, convertToParameterValue(b)); Object i = new Integer(143); assertEquals(143, convertToParameterValue(i)); Object l = new Long(7232); assertEquals(new Integer(7232), convertToParameterValue(l)); Object f = new Float(1523.234); assertEquals(1523.234f, convertToParameterValue(f)); Object d = new Double(1523.234); assertEquals(1523.234f, convertToParameterValue(d)); Object c = getClass(); assertTrue(convertToParameterValue(c) instanceof String); assertNotNull(convertToParameterValue(Collections.emptyList())); assertNotNull(convertToParameterValue(new Object[0])); }