Class AbstractListChildSerializer<T>

    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected AbstractListChildSerializer()
      Create a new serializer, only for use by subclasses.
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      protected T createNew​(int length, java.lang.reflect.AnnotatedType elementType)
      Create a new instance of the collection.
      protected T createNew​(int length, java.lang.reflect.Type elementType)
      Deprecated.
      for removal since 4.2.0, override createNew(int, AnnotatedType) instead to pass through annotation information
      T deserialize​(java.lang.reflect.AnnotatedType type, ConfigurationNode node)
      Deserialize an object (of the correct type) from the given configuration node.
      protected abstract void deserializeSingle​(int index, T collection, @Nullable java.lang.Object deserialized)
      Place a single deserialized value into the collection being deserialized.
      protected java.lang.reflect.AnnotatedType elementType​(java.lang.reflect.AnnotatedType containerType)
      Given the type of container, provide the expected type of an element.
      protected java.lang.reflect.Type elementType​(java.lang.reflect.Type containerType)
      Deprecated.
      for removal since 4.2.0, override elementType(AnnotatedType) instead to pass through annotation information
      @Nullable T emptyValue​(java.lang.reflect.AnnotatedType specificType, ConfigurationOptions options)
      Create an empty value of the appropriate type.
      protected abstract void forEachElement​(T collection, CheckedConsumer<java.lang.Object,​SerializationException> action)
      Perform the provided action on each element of the provided collection.
      void serialize​(java.lang.reflect.AnnotatedType type, @Nullable T obj, ConfigurationNode node)
      Serialize an object to the given configuration node.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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​(java.lang.reflect.AnnotatedType 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>
        Specified by:
        emptyValue in interface TypeSerializer.Annotated<T>
        Parameters:
        specificType - specific annotated subtype to create an empty value of
        options - options used from the loading node
        Returns:
        new empty value
      • elementType

        @ForOverride
        protected java.lang.reflect.AnnotatedType elementType​(java.lang.reflect.AnnotatedType 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.2.0
      • elementType

        @Deprecated
        protected java.lang.reflect.Type elementType​(java.lang.reflect.Type containerType)
                                              throws SerializationException
        Deprecated.
        for removal since 4.2.0, override elementType(AnnotatedType) instead to pass through annotation information
        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

        @ForOverride
        protected T createNew​(int length,
                              java.lang.reflect.AnnotatedType 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.2.0
      • createNew

        @ForOverride
        @Deprecated
        protected T createNew​(int length,
                              java.lang.reflect.Type elementType)
                       throws SerializationException
        Deprecated.
        for removal since 4.2.0, override createNew(int, AnnotatedType) instead to pass through annotation information
        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

        @ForOverride
        protected abstract void deserializeSingle​(int index,
                                                  T collection,
                                                  @Nullable java.lang.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