Interface DeserializeInput

All Superinterfaces:
ConfigurationDefinition.ReadOptions, DeserializeContext, ErrorContext.Source, UpdateListener

public interface DeserializeInput extends DeserializeContext
An object from a data tree, that is being processed for deserialization. See DataTree.

The object itself is provided by object().

Implementation

Instances of this type are implemented by the library and supplied to SerializeDeserialize implementations. Equality is not defined, and no thread safety is provided.

This type should not be implemented by library consumers. New methods may be added in the future, and this interface should be considered sealed. If library consumers decide to implement this interface, they might expose themselves to NoSuchMethodErrors if they pass their implementation to more up-to-date liaisons.

  • Method Details

    • entry

      @NonNull DataEntry entry()
      The entry of the object being deserialized.
      Returns:
      the entry
    • object

      default @NonNull Object object()
      The actual object which is being deserialized.

      This is merely entry().getValue(), meaning it is guaranteed to be one of the canonical values given by DataEntry: primitives, String, DataList, or DataTree.

      Returns:
      the object
    • requireString

      @NonNull LoadResult<@NonNull String> requireString()
      Requires the object to be a string
      Returns:
      the object as a string, or an error result if the type is mismatched
    • requireDataTree

      @NonNull LoadResult<@NonNull DataTree> requireDataTree()
      Requires the object to be a data tree, i.e. a map of key/value pairs.

      Callers may want to pair use of this method with the key mapper if they wish to read and write using string keys on the DataTree.

      Returns:
      the object as a data tree, or an error result if the type is mismatched
    • requireDataList

      @NonNull LoadResult<@NonNull DataList> requireDataList()
      Requires the object to be a list of data entries.
      Returns:
      the object as a data list, or an error result if the type is mismatched
    • makeChild

      @Deprecated @NonNull DeserializeInput makeChild(@NonNull Object value)
      Deprecated.
      This method will be removed in 2.0 in favor of makeChild(DataEntry, Object). That method requires the caller to supply the child value's location, so to replicate this method's behavior, you would need to number your calls to this method and pass "$" + idx as the location.
      Makes a child and prepares it for deserialization.

      The child value is supposed to be taken "from" this object. For example, an element in a list would be a child object of the list. The child value is checked to conform to DataEntry.validateValue(Object).

      Parameters:
      value - the child value to wrap
      Returns:
      deserializable input
      Throws:
      IllegalArgumentException - if DataEntry.validateValue(value) returns false
    • makeChild

      @NonNull DeserializeInput makeChild(@NonNull DataEntry entry, @NonNull Object locIdentiier)
      Makes a child at the given subkey and prepares it for deserialization.

      The child entry is supposed to be taken "from" this object. For example, an element in a list would be a child entry of the list.

      The keyPart argument provides a user recognizable string identifying where the child value is located. For example, list items can provide the index of the element.

      Parameters:
      entry - the child entry to wrap
      locIdentiier - an identifier for the child entry's location, based on toString()
      Returns:
      deserializable input