Class NullableWrapperConverters

java.lang.Object
org.springframework.data.util.NullableWrapperConverters

public abstract class NullableWrapperConverters extends Object
Converters to wrap and unwrap nullable wrapper types potentially being available on the classpath. Currently supported:
  • java.util.Optional
  • com.google.common.base.Optional
  • scala.Option
  • javaslang.control.Option
  • io.vavr.control.Option
Since:
2.4
Author:
Oliver Gierke, Mark Paluch, Christoph Strobl, Maciek Opała, Jens Schauder
  • Method Details

    • supports

      public static boolean supports(Class<?> type)
      Returns whether the given type is a supported wrapper type.
      Parameters:
      type - must not be null.
      Returns:
    • supportsUnwrapping

      public static boolean supportsUnwrapping(Class<?> type)
      Returns whether the given wrapper type supports unwrapping.
      Parameters:
      type - must not be null.
      Returns:
    • isSingleValue

      public static boolean isSingleValue(Class<?> type)
    • registerConvertersIn

      public static void registerConvertersIn(org.springframework.core.convert.converter.ConverterRegistry registry)
      Registers converters for wrapper types found on the classpath.
      Parameters:
      registry - must not be null.
    • unwrap

      @Nullable public static Object unwrap(@Nullable Object source)
      Unwraps the given source value in case it's one of the currently supported wrapper types detected at runtime.
      Parameters:
      source - can be null.
      Returns:
    • unwrapActualType

      public static TypeInformation<?> unwrapActualType(TypeInformation<?> type)
      Recursively unwraps well known wrapper types from the given TypeInformation.
      Parameters:
      type - must not be null.
      Returns:
      will never be null.