public static <T>T coerce(Object value,Class<T> cls){
  if (value == null || cls == null || cls.isAssignableFrom(value.getClass())) {
    return (T)value;
  }
  try {
    return (T)ConvertUtils.convert(value,cls);
  }
 catch (  ConversionException|InvalidAttributeException|IllegalArgumentException e) {
    throw new InvalidValueException(value,e.getMessage());
  }
}

public static < T > T coerce ( Object value , Class < T > cls ) { if ( value == null || cls == null || cls . isAssignableFrom ( value . getClass ( ) ) ) { return ( T ) value ; } try { return ( T ) ConvertUtils . convert ( value , cls ) ; } catch ( ConversionException | InvalidAttributeException | IllegalArgumentException e ) { throw new InvalidValueException ( value , e . getMessage ( ) ) ; } }
convert value to target class .
