Lines 343-349
Link Here
|
343 |
public final static Object coerceToType(final Object obj, final Class type) |
343 |
public final static Object coerceToType(final Object obj, final Class type) |
344 |
throws IllegalArgumentException { |
344 |
throws IllegalArgumentException { |
345 |
if (type == null || Object.class.equals(type) || |
345 |
if (type == null || Object.class.equals(type) || |
346 |
(obj != null && type.equals(obj.getClass()))) { |
346 |
(obj != null && type.isAssignableFrom(obj.getClass()))) { |
347 |
return obj; |
347 |
return obj; |
348 |
} |
348 |
} |
349 |
if (String.class.equals(type)) { |
349 |
if (String.class.equals(type)) { |
Lines 358-366
Link Here
|
358 |
if (Boolean.class.equals(type) || Boolean.TYPE == type) { |
358 |
if (Boolean.class.equals(type) || Boolean.TYPE == type) { |
359 |
return coerceToBoolean(obj); |
359 |
return coerceToBoolean(obj); |
360 |
} |
360 |
} |
361 |
if (obj != null && type.isAssignableFrom(obj.getClass())) { |
|
|
362 |
return obj; |
363 |
} |
364 |
if (type.isEnum()) { |
361 |
if (type.isEnum()) { |
365 |
return coerceToEnum(obj, type); |
362 |
return coerceToEnum(obj, type); |
366 |
} |
363 |
} |