Interface ObjectMapper<V>
- Type Parameters:
V
- mapped type
- All Known Subinterfaces:
ObjectMapper.Mutable<V>
Object mappers are created through a ObjectMapper.Factory
, either the default
one or one created with additional options. See that class's
documentation for details.
The object mapper can be accessed directly, through its factory()
,
or through a ConfigurationNode
's
ConfigurationNode.get(TypeToken)
method. To use a custom factory
instance through a node, a custom TypeSerializer has to be registered to the
TypeSerializerCollection
used
by the node.
- Since:
- 4.0.0
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interface
Provider for object mappers.static interface
An object mapper capable of loading data into an existing object. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Get whether or not this mapper is capable of creating new instances of its mapped type.static ObjectMapper.Factory.Builder
Create an empty builder.static ObjectMapper.Factory
factory()
Get the default object mapper factory instance.static ObjectMapper.Factory.Builder
Create a builder populated with default settings.fields()
Get the parameters that will be handled by this mapper.load
(ConfigurationNode source) Create a new object instance.The generic type of object that this mapper instance handles.void
save
(V value, ConfigurationNode target) Write data from the provided object to the target.
-
Method Details
-
factory
Get the default object mapper factory instance.This factory has the following characteristics:
- can resolve fields in empty-constructor objects and Records
- will try to resolve any field in objects
- supports
NodeKey
andSetting
annotations for customizing node resolution - uses the
NamingSchemes.LOWER_CASE_DASHED
naming scheme for other nodes - supports unlocalized
Matches
, andRequired
constraints - processes
Comment
annotations
- Returns:
- default factory
- Since:
- 4.0.0
-
emptyFactoryBuilder
Create an empty builder.This applies none of the standard formats, processors, constraints or resolvers. Unless you want to do something particularly specialized, you should probably be using
factoryBuilder()
.- Returns:
- new empty builder
- Since:
- 4.0.0
-
factoryBuilder
Create a builder populated with default settings.This builder is prepared to allow overriding any of the default object mapper features.
- Returns:
- new builder
- Since:
- 4.0.0
- See Also:
-
load
Create a new object instance.- Parameters:
source
- object source- Returns:
- new instance
- Throws:
SerializationException
- if any invalid data is present. Loading is done in stages, so any deserialization errors will occur before anything is written to objects.- Since:
- 4.0.0
-
save
Write data from the provided object to the target.- Parameters:
value
- value typetarget
- destination- Throws:
SerializationException
- if unable to fully save- Since:
- 4.0.0
-
fields
Get the parameters that will be handled by this mapper.- Returns:
- immutable list of fields
- Since:
- 4.0.0
-
mappedType
The generic type of object that this mapper instance handles.- Returns:
- object type
- Since:
- 4.0.0
-
canCreateInstances
boolean canCreateInstances()Get whether or not this mapper is capable of creating new instances of its mapped type.If this returns
false
,load(ConfigurationNode)
will always fail.- Returns:
- if the mapped type can be instantiated.
- Since:
- 4.0.0
-