Class AbstractListChildSerializer<T>

    • Constructor Detail

      • AbstractListChildSerializer

        protected AbstractListChildSerializer()
        Create a new serializer, only for use by subclasses.
        Since:
        4.1.0
    • Method Detail

      • emptyValue

        public @Nullable T emptyValue​(Type specificType,
                                      ConfigurationOptions options)
        Description copied from interface: TypeSerializer
        Create an empty value of the appropriate type.

        This method is for the most part designed to create empty collection types, though it may be useful for scalars in limited cases.

        Specified by:
        emptyValue in interface TypeSerializer<T>
        Parameters:
        specificType - specific subtype to create an empty value of
        options - options used from the loading node
        Returns:
        new empty value
      • elementType

        protected abstract Type elementType​(Type containerType)
                                     throws SerializationException
        Given the type of container, provide the expected type of an element. If the element type is not available, an exception must be thrown.
        Parameters:
        containerType - the type of container with type parameters resolved to the extent possible.
        Returns:
        the element type
        Throws:
        SerializationException - if the element type could not be detected
        Since:
        4.1.0
      • createNew

        protected abstract T createNew​(int length,
                                       Type elementType)
                                throws SerializationException
        Create a new instance of the collection. The returned instance must be mutable, but may have a fixed length.
        Parameters:
        length - the necessary collection length
        elementType - the type of element contained within the collection, as provided by elementType(Type)
        Returns:
        a newly created collection
        Throws:
        SerializationException - when an error occurs during the creation of the collection
        Since:
        4.1.0
      • deserializeSingle

        protected abstract void deserializeSingle​(int index,
                                                  T collection,
                                                  @Nullable Object deserialized)
                                           throws SerializationException
        Place a single deserialized value into the collection being deserialized.
        Parameters:
        index - location to set value at
        collection - collection to modify
        deserialized - value to add
        Throws:
        SerializationException - if object could not be coerced to an appropriate type.
        Since:
        4.1.0