Class DataSerializers

java.lang.Object
ru.progrm_jarvis.javacommons.data.DataSerializers

public final class DataSerializers extends Object
  • Method Details

    • booleanDataSerializer

      @NotNull public static @NotNull DataSerializer<@NotNull Boolean> booleanDataSerializer()
      Creates a data serializer for Boolean.
      Returns:
      data serializer for Boolean
    • byteDataSerializer

      @NotNull public static @NotNull DataSerializer<@NotNull Byte> byteDataSerializer()
      Creates a data serializer for Byte.
      Returns:
      data serializer for Byte
    • shortDataSerializer

      @NotNull public static @NotNull DataSerializer<@NotNull Short> shortDataSerializer()
      Creates a data serializer for Short.
      Returns:
      data serializer for Short
    • charDataSerializer

      @NotNull public static @NotNull DataSerializer<@NotNull Character> charDataSerializer()
      Creates a data serializer for Character.
      Returns:
      data serializer for Character
    • intDataSerializer

      @NotNull public static @NotNull DataSerializer<@NotNull Integer> intDataSerializer()
      Creates a data serializer for Integer.
      Returns:
      data serializer for Integer
    • longDataSerializer

      @NotNull public static @NotNull DataSerializer<@NotNull Long> longDataSerializer()
      Creates a data serializer for Long.
      Returns:
      data serializer for Long
    • floatDataSerializer

      @NotNull public static @NotNull DataSerializer<@NotNull Float> floatDataSerializer()
      Creates a data serializer for Float.
      Returns:
      data serializer for Float
    • doubleDataSerializer

      @NotNull public static @NotNull DataSerializer<@NotNull Double> doubleDataSerializer()
      Creates a data serializer for Double.
      Returns:
      data serializer for Double
    • stringDataSerializer

      @NotNull public static @NotNull DataSerializer<@NotNull String> stringDataSerializer()
      Creates a data serializer for String.
      Returns:
      data serializer for String
    • uuidDataSerializer

      @NotNull public static @NotNull DataSerializer<@NotNull UUID> uuidDataSerializer()
      Creates a data serializer for UUID.
      Returns:
      data serializer for UUID
    • collectionDataSerializer

      @NotNull public static <C extends Collection<T>, T> @NotNull DataSerializer<@NotNull C> collectionDataSerializer(@NonNull DataSerializers.SizeAwareFactory<C> collectionFactory, @NonNull @NonNull DataSerializer<T> elementSerializer)
      Creates a data serializer for the given collection type.
      Type Parameters:
      C - the type of the collection
      T - the type of the collection's elements
      Parameters:
      collectionFactory - factory used for creation of collections
      elementSerializer - serializer used for elements' serialization
      Returns:
      data serializer for the given collection type
    • collectionDataSerializer

      @NotNull public static <T> @NotNull DataSerializer<@NotNull Collection<T>> collectionDataSerializer(@NonNull @NonNull DataSerializer<T> elementSerializer)
      Type Parameters:
      T - the type of the collection's elements
      Parameters:
      elementSerializer - serializer used for elements' serialization
      Returns:
      data serializer for Collection
      API note
      there are no specific guarantees for the given collection
    • listDataSerializer

      @NotNull public static <T> @NotNull DataSerializer<@NotNull List<T>> listDataSerializer(@NonNull @NonNull DataSerializer<T> elementSerializer)
      Creates a data serializer for List.
      Type Parameters:
      T - the type of the list's elements
      Parameters:
      elementSerializer - serializer used for elements' serialization
      Returns:
      data serializer for List
      API note
      there are no specific guarantees for the given list
    • setDataSerializer

      @NotNull public static <T> @NotNull DataSerializer<@NotNull Set<T>> setDataSerializer(@NonNull @NonNull DataSerializer<T> elementSerializer)
      Creates a data serializer for Set.
      Type Parameters:
      T - the type of the set's elements
      Parameters:
      elementSerializer - serializer used for elements' serialization
      Returns:
      data serializer for Set
      API note
      there are no specific guarantees for the given set
    • mapDataSerializer

      @NotNull public static <M extends Map<K, V>, K, V> @NotNull DataSerializer<@NotNull M> mapDataSerializer(@NonNull DataSerializers.SizeAwareFactory<M> mapFactory, @NonNull @NonNull DataSerializer<K> keySerializer, @NonNull @NonNull DataSerializer<V> valueSerializer)
      Creates a data serializer for the given map type.
      Type Parameters:
      M - the type of the map
      K - the type of the maps' keys
      V - the type of the maps' values
      Parameters:
      mapFactory - factory used for creation of maps
      keySerializer - serializer used for keys' serialization
      valueSerializer - serializer used for values' serialization
      Returns:
      data serializer for the given map type
    • mapDataSerializer

      @NotNull public static <K, V> @NotNull DataSerializer<@NotNull Map<K,V>> mapDataSerializer(@NonNull @NonNull DataSerializer<K> keySerializer, @NonNull @NonNull DataSerializer<V> valueSerializer)
      Creates a data serializer for Map.
      Type Parameters:
      K - the type of the maps' keys
      V - the type of the maps' values
      Parameters:
      keySerializer - serializer used for keys' serialization
      valueSerializer - serializer used for values' serialization
      Returns:
      data serializer for Collection
      API note
      there are no specific guarantees for the given map
    • namedEnumDataSerializer

      public static <E extends Enum<E>> DataSerializer<@NotNull E> namedEnumDataSerializer(@NonNull @NonNull Class<E> enumType)
      Creates a data serializer for the given enum type which will implement stable serialization which will rely on enum names.
      Type Parameters:
      E - the type of the enum
      Parameters:
      enumType - class object representing the enum type
      Returns:
      data serializer for the given enum type
    • ordinalEnumDataSerializer

      public static <E extends Enum<E>> DataSerializer<@NotNull E> ordinalEnumDataSerializer(@NonNull @NonNull Class<E> enumType)
      Creates a data serializer for the given enum type which will implement unstable serialization which will rely on enum ordinal.
      Type Parameters:
      E - the type of the enum
      Parameters:
      enumType - class object representing the enum type
      Returns:
      data serializer for the given enum type
    • localDateTimeDataSerializer

      @NotNull public static @NotNull DataSerializer<@NotNull LocalDateTime> localDateTimeDataSerializer(@NotNull @NotNull ZoneOffset zoneOffset)
      Parameters:
      zoneOffset - zone offset used for local time management
      Returns:
      data serializer for LocalDateTime
    • localDateDataSerializer

      @NotNull public static @NotNull DataSerializer<@NotNull LocalDate> localDateDataSerializer()
      Creates a data serializer for LocalDate.
      Returns:
      data serializer for LocalDate
    • localTimeDataSerializer

      @NotNull public static @NotNull DataSerializer<@NotNull LocalTime> localTimeDataSerializer()
      Creates a data serializer for LocalTime.
      Returns:
      data serializer for LocalTime
    • instantDataSerializer

      @NotNull public static @NotNull DataSerializer<@NotNull Instant> instantDataSerializer()
      Creates a data serializer for Instant.
      Returns:
      data serializer for Instant