Class TypeSerializerCollection.Builder

    • Method Detail

      • register

        public <T> TypeSerializerCollection.Builder register​(TypeToken<T> type,
                                                             TypeSerializer<? super T> serializer)
        Register a type serializer for a given type.

        Serializers registered will match all subclasses of the provided type, as well as unwrapped primitive equivalents of the type.

        Type Parameters:
        T - the type to generify around
        Parameters:
        type - the type to accept
        serializer - the serializer that will be serialized with
        Returns:
        this builder
        Since:
        4.0.0
      • register

        public <T> TypeSerializerCollection.Builder register​(Class<T> type,
                                                             TypeSerializer<? super T> serializer)
        Register a type serializer for a given type.

        Serializers registered will match all subclasses of the provided type, as well as unboxed primitive equivalents of the type.

        Type Parameters:
        T - the type to generify around
        Parameters:
        type - the type to accept
        serializer - the serializer that will be serialized with
        Returns:
        this builder
        Since:
        4.0.0
      • register

        public <T> TypeSerializerCollection.Builder register​(Predicate<Type> test,
                                                             TypeSerializer<? super T> serializer)
        Register a type serializer matching against a given predicate.
        Type Parameters:
        T - the type parameter
        Parameters:
        test - the predicate to match types against
        serializer - the serializer to serialize matching types with
        Returns:
        this builder
        Since:
        4.0.0
      • register

        public <T> TypeSerializerCollection.Builder register​(ScalarSerializer<T> serializer)
        Register a scalar serializer with its own attached type token.

        Serializers registered will match all subclasses of the provided type, as well as unboxed primitive equivalents of the type.

        Type Parameters:
        T - value type
        Parameters:
        serializer - serializer to register
        Returns:
        this builder
        Since:
        4.0.0
      • registerExact

        public <T> TypeSerializerCollection.Builder registerExact​(TypeToken<T> type,
                                                                  TypeSerializer<? super T> serializer)
        Register an exact type serializer for a given type.

        Serializers will only match exact object types. For example, a serializer registered for List<String> would not match when ArrayList<String> is queried.

        Type Parameters:
        T - the type to generify around
        Parameters:
        type - the type to accept
        serializer - the serializer that will be serialized with
        Returns:
        this builder
        Since:
        4.0.0
      • registerExact

        public <T> TypeSerializerCollection.Builder registerExact​(Class<T> type,
                                                                  TypeSerializer<? super T> serializer)
        Register an exact type serializer for a given type.

        Serializers will only match exact object types. For example, a serializer registered for List<String> would not match when ArrayList<String> is queried.

        Type Parameters:
        T - the type to generify around
        Parameters:
        type - the type to accept
        serializer - the serializer that will be serialized with
        Returns:
        this builder
        Since:
        4.0.0
      • registerExact

        public <T> TypeSerializerCollection.Builder registerExact​(ScalarSerializer<T> serializer)
        Register a scalar serializer with its own attached type token.

        Serializers will only match exact object types. For example, a serializer registered for List<String> would not match when ArrayList<String> is queried.

        Type Parameters:
        T - value type
        Parameters:
        serializer - serializer to register
        Returns:
        this builder
        Since:
        4.0.0
      • registerAll

        public TypeSerializerCollection.Builder registerAll​(TypeSerializerCollection other)
        Register all serializers from other into this collection.

        Creating a child collection should be preferred, but when merging multiple sets of serializers together, directly adding other collections may be the best choice.

        Parameters:
        other - source collection
        Returns:
        this builder
        Since:
        4.0.0