Class AbstractListChildSerializer<T>
java.lang.Object
org.spongepowered.configurate.serialize.AbstractListChildSerializer<T>
- Type Parameters:
- T- the type of collection to serialize
- All Implemented Interfaces:
- TypeSerializer<T>,- TypeSerializer.Annotated<T>
public abstract class AbstractListChildSerializer<T>
extends Object
implements TypeSerializer.Annotated<T>
A serializer for nodes that are 'list-like' (i.e may be stored in nodes where 
ConfigurationNode.isList() is
 true.- Since:
- 4.1.0
- 
Nested Class SummaryNested classes/interfaces inherited from interface org.spongepowered.configurate.serialize.TypeSerializerTypeSerializer.Annotated<V>
- 
Constructor SummaryConstructorsModifierConstructorDescriptionprotectedCreate a new serializer, only for use by subclasses.
- 
Method SummaryModifier and TypeMethodDescriptionprotected TcreateNew(int length, AnnotatedType elementType) Create a new instance of the collection.protected TDeprecated.final Tdeserialize(AnnotatedType type, ConfigurationNode node) Deserialize an object (of the correct type) from the given configuration node.protected abstract voiddeserializeSingle(int index, T collection, @Nullable Object deserialized) Place a single deserialized value into the collection being deserialized.protected AnnotatedTypeelementType(AnnotatedType containerType) Given the type of container, provide the expected type of an element.protected TypeelementType(Type containerType) Deprecated.for removal since 4.2.0, overrideelementType(AnnotatedType)instead to pass through annotation information@Nullable TemptyValue(AnnotatedType specificType, ConfigurationOptions options) Create an empty value of the appropriate type.protected abstract voidforEachElement(T collection, CheckedConsumer<Object, SerializationException> action) Perform the provided action on each element of the provided collection.final voidserialize(AnnotatedType type, @Nullable T obj, ConfigurationNode node) Serialize an object to the given configuration node.Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.spongepowered.configurate.serialize.TypeSerializer.Annotateddeserialize, emptyValue, serialize
- 
Constructor Details- 
AbstractListChildSerializerprotected AbstractListChildSerializer()Create a new serializer, only for use by subclasses.- Since:
- 4.1.0
 
 
- 
- 
Method Details- 
deserializepublic final T deserialize(AnnotatedType type, ConfigurationNode node) throws SerializationException Description copied from interface:TypeSerializerDeserialize an object (of the correct type) from the given configuration node.- Specified by:
- deserializein interface- TypeSerializer<T>
- Specified by:
- deserializein interface- TypeSerializer.Annotated<T>
- Parameters:
- type- the annotated type of return value required
- node- the node containing serialized data
- Returns:
- an object
- Throws:
- SerializationException- if the presented data is invalid
 
- 
serializepublic final void serialize(AnnotatedType type, @Nullable T obj, ConfigurationNode node) throws SerializationException Description copied from interface:TypeSerializerSerialize an object to the given configuration node.- Specified by:
- serializein interface- TypeSerializer<T>
- Specified by:
- serializein interface- TypeSerializer.Annotated<T>
- Parameters:
- type- the annotated type of the input object
- obj- the object to be serialized
- node- the node to write to
- Throws:
- SerializationException- if the object cannot be serialized
 
- 
emptyValueDescription copied from interface:TypeSerializerCreate 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:
- emptyValuein interface- TypeSerializer<T>
- Specified by:
- emptyValuein 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 AnnotatedType elementType(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
 
- 
elementTypeDeprecated.for removal since 4.2.0, overrideelementType(AnnotatedType)instead to pass through annotation informationGiven 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, 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, Type elementType) throws SerializationException Deprecated.for removal since 4.2.0, overridecreateNew(int, AnnotatedType)instead to pass through annotation informationCreate 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
 
- 
forEachElement@ForOverride protected abstract void forEachElement(T collection, CheckedConsumer<Object, SerializationException> action) throws SerializationExceptionPerform the provided action on each element of the provided collection.This is equivalent to a foreach loop on the collection - Parameters:
- collection- the collection to act on
- action- the action to perform
- Throws:
- SerializationException- when thrown by the underlying action
- Since:
- 4.1.0
 
- 
deserializeSingle@ForOverride 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
 
 
- 
createNew(int, AnnotatedType)instead to pass through annotation information