Package net.obvj.confectory.mapper
Class JacksonXMLToObjectMapper<T>
- java.lang.Object
-
- net.obvj.confectory.mapper.JacksonJsonToObjectMapper<T>
-
- net.obvj.confectory.mapper.JacksonXMLToObjectMapper<T>
-
- Type Parameters:
T- the target type to be produced by thisMapper(the target class may contain Jackson annotations for due mapping -- e.g.:@JacksonXmlRootElement)
- All Implemented Interfaces:
Mapper<T>
- Direct Known Subclasses:
JacksonXMLToJsonNodeMapper
public class JacksonXMLToObjectMapper<T> extends JacksonJsonToObjectMapper<T> implements Mapper<T>
A specializedMapperthat loads the contents of a valid XMLSource(e.g.: file, URL, string) into POJO (Plain Old Java Object), using Jackson'sXmlMapper.Additional details may be found at Jackson's official documentation.
Since version 2.4.0, this class supports lookup and registration of Jackson modules by default. However, since modules lookup is considered a potentially expensive operation, it can be disabled by setting the
disableModulesflag in the constructor:new JacksonXMLToObjectMapper(Class<?>, boolean)Note: To avoid a performance overhead, Jackson modules lookup happens automatically at the first instantiation of a
JacksonJsonToObjectMapperwith enable support for modules.- Since:
- 0.3.0
- Author:
- oswaldo.bapvic.jr (Oswaldo Junior)
-
-
Constructor Summary
Constructors Constructor Description JacksonXMLToObjectMapper(Class<T> targetType)Builds a new XML mapper with the specified target type and support for Jackson modules enabled by default.JacksonXMLToObjectMapper(Class<T> targetType, boolean disableModules)Builds a new XML mapper with the specified target type.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Tapply(InputStream inputStream)-
Methods inherited from class net.obvj.confectory.mapper.JacksonJsonToObjectMapper
configurationHelper, reloadModulesCache, resetModulesCache
-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface net.obvj.confectory.mapper.Mapper
configurationHelper
-
-
-
-
Constructor Detail
-
JacksonXMLToObjectMapper
public JacksonXMLToObjectMapper(Class<T> targetType)
Builds a new XML mapper with the specified target type and support for Jackson modules enabled by default.- Parameters:
targetType- the target type to be produced by thisMapper
-
JacksonXMLToObjectMapper
public JacksonXMLToObjectMapper(Class<T> targetType, boolean disableModules)
Builds a new XML mapper with the specified target type.- Parameters:
targetType- the target type to be produced by thisMapperdisableModules- disable Jackson modules; useful for an optimized processing if Jackson add-ons are NOT required- Since:
- 2.4.0
-
-
Method Detail
-
apply
public T apply(InputStream inputStream) throws IOException
- Specified by:
applyin interfaceMapper<T>- Overrides:
applyin classJacksonJsonToObjectMapper<T>- Throws:
IOException
-
-