Skip to content

Commit 4eb5f91

Browse files
committed
ConversionUtils: flesh out other canConvert method
The canConvert(Object, Class) method has the same limitations as canConvert(Object, Type) and should document them the same way.
1 parent 9ed9cca commit 4eb5f91

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/main/java/org/scijava/util/ConversionUtils.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,17 @@ public static boolean canConvert(final Object src, final Type dest) {
333333
}
334334

335335
/**
336-
* Checks whether the given object can be converted to the specified type.
336+
* Checks whether the given object's type can be converted to the specified
337+
* type.
338+
* <p>
339+
* Note that this does <em>not</em> necessarily entail that
340+
* {@link #convert(Object, Class)} on that specific object will succeed. For
341+
* example: {@code canConvert("5.1", int.class)} will return {@code true}
342+
* because a {@link String} can in general be converted to an {@code int}, but
343+
* calling {@code convert("5.1", int.class)} will throw a
344+
* {@link NumberFormatException} when the conversion is actually attempted
345+
* via the {@link Integer#Integer(String)} constructor.
346+
* </p>
337347
*
338348
* @see #convert(Object, Class)
339349
*/

0 commit comments

Comments
 (0)