Class ConverterAwareMappingSpannerEntityWriter

All Implemented Interfaces:

public class ConverterAwareMappingSpannerEntityWriter extends Object implements SpannerEntityWriter
The primary class for adding values from entity objects to Mutation.WriteBuilder for the purpose of creating mutations for Spanner.
  • Field Details

    • singleItemTypeValueBinderMethodMap

      public static final Map<Class<?>,BiFunction<,?,?>> singleItemTypeValueBinderMethodMap
      A map of types to functions that binds them to `ValueBinder` objects.
  • Method Details

    • findFirstCompatibleSpannerSingleItemNativeType

      public static Class<?> findFirstCompatibleSpannerSingleItemNativeType(Predicate<Class> testFunc)
    • findFirstCompatibleSpannerMultipleItemNativeType

      public static Class<?> findFirstCompatibleSpannerMultipleItemNativeType(Predicate<Class> testFunc)
    • write

      public void write(Object source, MultipleValueBinder sink)
      Specified by:
      write in interface<Object,MultipleValueBinder>
    • write

      public void write(Object source, MultipleValueBinder sink, Set<String> includeColumns)
      Writes an object's properties to the sink.
      Specified by:
      write in interface SpannerEntityWriter
      source - the object to write
      sink - the sink to which to write
      includeColumns - the columns to write. If null, then all columns are written.
    • convertToKey

      public convertToKey(Object key)
      Description copied from interface: SpannerEntityWriter
      Convert a given object to a Cloud Spanner key.
      Specified by:
      convertToKey in interface SpannerEntityWriter
      key - the object containing the key values. This can already be a Cloud Spanner key, a single key component, or an array of key components.
      the Cloud Spanner key.
    • getSpannerWriteConverter

      public SpannerWriteConverter getSpannerWriteConverter()
      Description copied from interface: SpannerEntityWriter
      Get the SpannerWriteConverter used to convert types into Cloud Spanner compatible types.
      Specified by:
      getSpannerWriteConverter in interface SpannerEntityWriter
      a SpannerWriteConverter
    • attemptSetIterableValueOnBinder

      public static boolean attemptSetIterableValueOnBinder(Iterable<Object> value, valueBinder, SpannerCustomConverter writeConverter, Class innerType)
      Bind an iterable value to a ValueBinder.
      value - the value to bind.
      valueBinder - the binder that accepts the value.
      writeConverter - the converter to use to convert the values.
      innerType - the type of the items in the iterable.
      true if the binding was successful.
    • attemptBindSingleValue

      public static boolean attemptBindSingleValue(Object propertyValue, Class<?> propertyType, valueBinder, SpannerCustomConverter spannerCustomConverter)
      Bind a value to a ValueBinder.
      propertyValue - the value to bind.
      propertyType - the type of the value to bind.
      valueBinder - the binder.
      spannerCustomConverter - the converter used to convert if necessary.
      true if the value was bound successfully.