Interface ObjectMapper<V>

Type Parameters:
V - mapped type
All Known Subinterfaces:
ObjectMapper.Mutable<V>

public interface ObjectMapper<V>
A mapper that converts between configuration nodes and Java objects.

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
  • Method Details

    • factory

      Get the default object mapper factory instance.

      This factory has the following characteristics:

      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

      void save(V value, ConfigurationNode target) throws SerializationException
      Write data from the provided object to the target.
      Parameters:
      value - value type
      target - destination
      Throws:
      SerializationException - if unable to fully save
      Since:
      4.0.0
    • fields

      List<? extends FieldData<?,V>> 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

      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