Skip to content

Commit 9ed9cca

Browse files
committed
ConversionUtils: flesh out canConvert javadoc
1 parent 711dd51 commit 9ed9cca

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
@@ -313,7 +313,17 @@ public static boolean canConvert(final Class<?> src, final Class<?> dest) {
313313
}
314314

315315
/**
316-
* Checks whether the given object's type can be converted to the specified type.
316+
* Checks whether the given object's type can be converted to the specified
317+
* type.
318+
* <p>
319+
* Note that this does <em>not</em> necessarily entail that
320+
* {@link #convert(Object, Type)} on that specific object will succeed. For
321+
* example: {@code canConvert("5.1", int.class)} will return {@code true}
322+
* because a {@link String} can in general be converted to an {@code int}, but
323+
* calling {@code convert("5.1", int.class)} will throw a
324+
* {@link NumberFormatException} when the conversion is actually attempted
325+
* via the {@link Integer#Integer(String)} constructor.
326+
* </p>
317327
*
318328
* @see #convert(Object, Type)
319329
*/

0 commit comments

Comments
 (0)