Package org.geotools.util
Class Converters
Object
Converters
Convenience class for converting an object from one type to an object of another.
- Since:
- 2.4
- Author:
- Justin Deoliveira, The Open Planning Project
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> T
Converts an object of a particular type into an object of a different type.static <T> T
Converts an object of a particular type into an object of a different type.static Set<ConverterFactory>
getConverterFactories
(Class<?> source, Class<?> target) Returns a set of all availableConverterFactory
's which can handle convert from the source to destination class.static Set<ConverterFactory>
getConverterFactories
(Hints hints) Returns a set of all available implementations for theConverterFactory
interface.
-
Constructor Details
-
Converters
public Converters()
-
-
Method Details
-
getConverterFactories
Returns a set of all available implementations for theConverterFactory
interface.- Parameters:
hints
- An optional map of hints, ornull
if none.- Returns:
- Set of available ConverterFactory implementations.
-
getConverterFactories
Returns a set of all availableConverterFactory
's which can handle convert from the source to destination class.This method essentially returns all factories in which the following returns non null.
factory.createConverter( source, target );
- Since:
- 2.5
-
convert
Converts an object of a particular type into an object of a different type.Convenience for
convert(Object, Class, Hints)
- Parameters:
source
- The object to convert.target
- The type of the converted value.- Returns:
- The converted value as an instance of target, or
null
if a converter could not be found - Since:
- 2.4
-
convert
Converts an object of a particular type into an object of a different type.This method uses the
ConverterFactory
extension point to find a converter capable of performing the conversion. The first converter found is the one used. Using this class there is no way to guarantee which converter will be used.- Parameters:
source
- The object to convert.target
- The type of the converted value.hints
- Any hints for the converter factory.- Returns:
- The converted value as an instance of target, or
null
if a converter could not be found. - Since:
- 2.4
-