Class ValueSerialiserMap

java.lang.Object
space.arim.dazzleconf.serialiser.ValueSerialiserMap

public final class ValueSerialiserMap extends Object
An immutable map of value serialisers, keyed by the type which they serialise.
Author:
A248
  • Method Details

    • of

      public static ValueSerialiserMap of(Collection<? extends ValueSerialiser<?>> serialisers)
      Creates from a collection of serialisers. If any two serialisers specify the same target type (ValueSerialiser.getTargetClass()), IllegalArgumentException is thrown
      Parameters:
      serialisers - the value serialisers
      Returns:
      the value serialiser map
      Throws:
      NullPointerException - if any serialiser is null
      IllegalArgumentException - if any value serialisers conflict
    • of

      public static ValueSerialiserMap of(Map<Class<?>,​? extends ValueSerialiser<?>> serialisers)
      Creates from a map of serialisers. If any serialisers are at a mismatched key, IllegalArgumentException is thrown
      Parameters:
      serialisers - the value serialisers
      Returns:
      the value serialiser map
      Throws:
      NullPointerException - if any serialiser is null
      IllegalArgumentException - if any value serialisers are at a mismatched key
    • empty

      public static ValueSerialiserMap empty()
      Gets an empty value serialiser map
      Returns:
      an empty map
    • getSerialiser

      @Deprecated public <T> ValueSerialiser<T> getSerialiser(Class<T> type)
      Deprecated.
      Gets the value serialiser for a given type
      Type Parameters:
      T - the type
      Parameters:
      type - the type class
      Returns:
      the value serialiser for the type or null if there is none
    • getSerialiserFor

      public <T> Optional<ValueSerialiser<T>> getSerialiserFor(Class<T> type)
      Gets the value serialiser for a given type
      Type Parameters:
      T - the type
      Parameters:
      type - the type class
      Returns:
      the value serialiser for the type or an empty optional if there is none
    • asMap

      public Map<Class<?>,​ValueSerialiser<?>> asMap()
      Gets this value serialiser map as a Map. This map is immutable.
      Returns:
      the map of classes to value serialisers, never null
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object object)
      Overrides:
      equals in class Object