public static Object convert(Object value, Class<?> to) { if (value == null) { // lets avoid NullPointerException when converting to boolean for null values if (boolean.class.isAssignableFrom(to)) { return Boolean.FALSE; } return null; } // eager same instance type test to avoid the overhead of invoking the type converter // if already same type if (to.isInstance(value)) { return to.cast(value); } // lookup converter Converter c = lookupConverter(value.getClass(), to); if (c != null) { return c.convert(value); } else { return null; } }
TypeConversionSupport.Converter converter = TypeConversionSupport.lookupConverter(value.getClass(), to); if (converter != null) { return converter.convert(value);
public static String convertToString(Object value, Class to) { if (value == null) { return null; } // already a String if (value instanceof String) { return (String) value; } // special for String[] as we do not want to use a PropertyEditor for that if (String[].class.isInstance(value)) { String[] array = (String[]) value; return StringArrayConverter.convertToString(array); } // special for String to List<ActiveMQDestination> as we do not want to use a PropertyEditor for that if (List.class.isInstance(value)) { // if the list is a ActiveMQDestination, then return a comma list String answer = StringToListOfActiveMQDestinationConverter.convertFromActiveMQDestination(value); if (answer != null) { return answer; } } TypeConversionSupport.Converter converter = TypeConversionSupport.lookupConverter(value.getClass(), String.class); if (converter != null) { return (String) converter.convert(value); } else { throw new IllegalArgumentException("Cannot convert from " + value.getClass() + " to " + to + " with value " + value); } }
public static Object convert(Object value, Class<?> to) { if (value == null) { // lets avoid NullPointerException when converting to boolean for null values if (boolean.class.isAssignableFrom(to)) { return Boolean.FALSE; } return null; } // eager same instance type test to avoid the overhead of invoking the type converter // if already same type if (to.isInstance(value)) { return to.cast(value); } // lookup converter Converter c = lookupConverter(value.getClass(), to); if (c != null) { return c.convert(value); } else { return null; } }
public static Object convert(Object value, Class<?> to) { if (value == null) { // lets avoid NullPointerException when converting to boolean for null values if (boolean.class.isAssignableFrom(to)) { return Boolean.FALSE; } return null; } // eager same instance type test to avoid the overhead of invoking the type converter // if already same type if (to.isInstance(value)) { return to.cast(value); } // lookup converter Converter c = lookupConverter(value.getClass(), to); if (c != null) { return c.convert(value); } else { return null; } }
public static Object convert(Object value, Class<?> to) { if (value == null) { // lets avoid NullPointerException when converting to boolean for null values if (boolean.class.isAssignableFrom(to)) { return Boolean.FALSE; } return null; } // eager same instance type test to avoid the overhead of invoking the type converter // if already same type if (to.isInstance(value)) { return to.cast(value); } // lookup converter Converter c = lookupConverter(value.getClass(), to); if (c != null) { return c.convert(value); } else { return null; } }
TypeConversionSupport.Converter converter = TypeConversionSupport.lookupConverter(value.getClass(), to); if (converter != null) { return converter.convert(value);
TypeConversionSupport.Converter converter = TypeConversionSupport.lookupConverter(value.getClass(), to); if (converter != null) { return converter.convert(value);
TypeConversionSupport.Converter converter = TypeConversionSupport.lookupConverter(value.getClass(), to); if (converter != null) { return converter.convert(value);
public static String convertToString(Object value, Class to) { if (value == null) { return null; } // already a String if (value instanceof String) { return (String) value; } // special for String[] as we do not want to use a PropertyEditor for that if (String[].class.isInstance(value)) { String[] array = (String[]) value; return StringArrayConverter.convertToString(array); } // special for String to List<ActiveMQDestination> as we do not want to use a PropertyEditor for that if (List.class.isInstance(value)) { // if the list is a ActiveMQDestination, then return a comma list String answer = StringToListOfActiveMQDestinationConverter.convertFromActiveMQDestination(value); if (answer != null) { return answer; } } TypeConversionSupport.Converter converter = TypeConversionSupport.lookupConverter(value.getClass(), String.class); if (converter != null) { return (String) converter.convert(value); } else { throw new IllegalArgumentException("Cannot convert from " + value.getClass() + " to " + to + " with value " + value); } }
public static String convertToString(Object value, Class to) { if (value == null) { return null; } // already a String if (value instanceof String) { return (String) value; } // special for String[] as we do not want to use a PropertyEditor for that if (String[].class.isInstance(value)) { String[] array = (String[]) value; return StringArrayConverter.convertToString(array); } // special for String to List<ActiveMQDestination> as we do not want to use a PropertyEditor for that if (List.class.isInstance(value)) { // if the list is a ActiveMQDestination, then return a comma list String answer = StringToListOfActiveMQDestinationConverter.convertFromActiveMQDestination(value); if (answer != null) { return answer; } } TypeConversionSupport.Converter converter = TypeConversionSupport.lookupConverter(value.getClass(), String.class); if (converter != null) { return (String) converter.convert(value); } else { throw new IllegalArgumentException("Cannot convert from " + value.getClass() + " to " + to + " with value " + value); } }
public static String convertToString(Object value, Class to) { if (value == null) { return null; } // already a String if (value instanceof String) { return (String) value; } // special for String[] as we do not want to use a PropertyEditor for that if (String[].class.isInstance(value)) { String[] array = (String[]) value; return StringArrayConverter.convertToString(array); } // special for String to List<ActiveMQDestination> as we do not want to use a PropertyEditor for that if (List.class.isInstance(value)) { // if the list is a ActiveMQDestination, then return a comma list String answer = StringToListOfActiveMQDestinationConverter.convertFromActiveMQDestination(value); if (answer != null) { return answer; } } TypeConversionSupport.Converter converter = TypeConversionSupport.lookupConverter(value.getClass(), String.class); if (converter != null) { return (String) converter.convert(value); } else { throw new IllegalArgumentException("Cannot convert from " + value.getClass() + " to " + to + " with value " + value); } }