public class NullConverter extends AbstractConverter<Object,Object>
Converter
implementation for handling null
values. Returns
null
when given a null
source or null
destination.
By running at Priority.EXTREMELY_HIGH
, other converters should not
need to worry about null
source or destination parameters.
Constructor and Description |
---|
NullConverter() |
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(Class<?> src,
Type 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.
|
boolean |
canConvert(Object src,
Type 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() |
populateInputCandidates, supports
getInfo, getPriority, setInfo, setPriority, toString
context, getContext
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
canConvert, convert, convert, getType
getIdentifier, log
context, getContext, setContext
compareTo, getPriority, setPriority
getInfo, setInfo
getLocation
getVersion
public boolean canConvert(Object src, Type dest)
Converter
Converter.convert(Object, Type)
public boolean canConvert(Object src, Class<?> dest)
Converter
Converter.convert(Object, Class)
public boolean canConvert(Class<?> src, Type dest)
Converter
Note that this does not necessarily entail that
Converter.convert(Object, Type)
on a specific object of the given source
class will succeed. For example:
canConvert(String.class, List<Integer>)
will return true
because a String
can in general be converted to an Integer
and then wrapped into a List
, but calling
convert("5.1", List<Integer>)
will throw a
NumberFormatException
when the conversion is actually attempted via
the Integer(String)
constructor.
Converter.convert(Object, Type)
public boolean canConvert(Class<?> src, Class<?> dest)
Converter
Note that this does not necessarily entail that
Converter.convert(Object, Class)
on a specific object of the given source
class will succeed. For example:
canConvert(String.class, 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.
Converter.convert(Object, Class)
public <T> T convert(Object src, Class<T> dest)
Converter
String
, 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 © 2009–2023 SciJava. All rights reserved.