Class SerializerRegistry

java.lang.Object
de.iip_ecosphere.platform.transport.serialization.SerializerRegistry

public class SerializerRegistry extends Object
A registry for serializers to be able to handle also nested types on-demand. All relevant serializers must be registered for correct functionality.
Author:
Holger Eichelberger, SSE
  • Field Details

  • Constructor Details

    • SerializerRegistry

      public SerializerRegistry()
  • Method Details

    • resetDefaults

      public static void resetDefaults()
      Re-registers the default serizalizer types.
    • getSerializer

      public static <T> Serializer<T> getSerializer(Class<T> type)
      Returns a serializer instance.
      Type Parameters:
      T - the data type to be handled by the serializer
      Parameters:
      type - the type to return the serializer for
      Returns:
      the serializer, null if no such serializer is registered
    • hasSerializer

      public static boolean hasSerializer(Class<?> type)
      Returns whether a serializer is known for the given type.
      Parameters:
      type - the type to query for
      Returns:
      true if there is a registered serizalizer, false else
    • registerSerializer

      public static <T> void registerSerializer(Class<? extends Serializer<T>> type) throws IllegalArgumentException
      Registers a serializer through its type. An accessible no-arg constructor is required for type.
      Type Parameters:
      T - the type to be serialized
      Parameters:
      type - the type of the serializer to register
      Throws:
      IllegalArgumentException - if the required no-arg constructor on type cannot be found, called or executed, i.e., there is no instance to register
    • registerSerializer

      public static <T> void registerSerializer(Serializer<T> serializer)
      Registers a serializer.
      Type Parameters:
      T - the type of the data
      Parameters:
      serializer - the serializer instance (must not be null)
    • unregisterSerializer

      public static void unregisterSerializer(Serializer<?> serializer)
      Unregisters a serializer.
      Parameters:
      serializer - the serializer instance to unregister (must not be null)
    • unregisterSerializer

      public static void unregisterSerializer(Class<?> type)
      Unregisters a serializer.
      Parameters:
      type - the serializer type to unregister
    • getName

      public static String getName()
      Returns the descriptive name of this factory indicating the utilized wire format.
      Returns:
      the descriptive name
    • setName

      public static String setName(String name)
      Changes the descriptive name of this factory indicating the utilized wire format.
      Parameters:
      name - the descriptive name
      Returns:
      the descriptive name before this call