public class CastingConverter extends AbstractConverter<Object,Object>
Converter implementation to do direct casting.| Constructor and Description |
|---|
CastingConverter() |
| Modifier and Type | Method and Description |
|---|---|
boolean |
canConvert(Class<?> src,
Class<?> dest)
Checks whether objects of the given class can be converted to the specified
type.
|
boolean |
canConvert(Object src,
Class<?> dest)
Checks whether the given object's type can be converted to the specified
type.
|
<T> T |
convert(Object src,
Class<T> dest)
Converts the given object to an object of the specified type.
|
Class<Object> |
getInputType() |
Class<Object> |
getOutputType() |
canConvert, canConvert, canConvert, convert, convert, getType, populateInputCandidates, supportsgetInfo, getPriority, setInfo, setPriority, toStringcontext, getContextclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetIdentifier, logcontext, getContext, setContextcompareTo, getPriority, setPrioritygetInfo, setInfogetLocationgetVersionpublic boolean canConvert(Object src, Class<?> dest)
Converter
Note that this does not necessarily entail that
Converter.convert(Object, Class) on that specific object will succeed. For
example: canConvert("5.1", int.class) will return true
because a String can in general be converted to an int, but
calling convert("5.1", int.class) will throw a
NumberFormatException when the conversion is actually attempted via
the Integer(String) constructor.
canConvert in interface Converter<Object,Object>canConvert in class AbstractConverter<Object,Object>Converter.convert(Object, Class)public boolean canConvert(Class<?> src, Class<?> dest)
ConvertercanConvert in interface Converter<Object,Object>canConvert in class AbstractConverter<Object,Object>Converter.convert(Object, Class)public <T> T convert(Object src, Class<T> dest)
ConverterString, which uses the
Object.toString() method instead). In the case of primitive types,
returns an object of the corresponding wrapped type. If the destination
type does not have an appropriate constructor, returns null.T - Type to which the object should be converted.src - The object to convert.dest - Type to which the object should be converted.public Class<Object> getOutputType()
Class this Converter produces as output.Copyright © 2015–2022 SciJava. All rights reserved.