Class ConverterAwareMappingSpannerEntityWriter
java.lang.Object
com.google.cloud.spring.data.spanner.core.convert.ConverterAwareMappingSpannerEntityWriter
- All Implemented Interfaces:
SpannerEntityWriter,org.springframework.data.convert.EntityWriter<Object,MultipleValueBinder>
The primary class for adding values from entity objects to
Mutation.WriteBuilder for the purpose
of creating mutations for Spanner.- Since:
- 1.1
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Map<Class<?>,BiFunction<com.google.cloud.spanner.ValueBinder, ?, ?>> A map of types to functions that binds them to `ValueBinder` objects. -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanattemptBindSingleValue(Object propertyValue, Class<?> propertyType, com.google.cloud.spanner.ValueBinder valueBinder, SpannerCustomConverter spannerCustomConverter) Bind a value to a ValueBinder.static booleanattemptSetIterableValueOnBinder(Iterable<Object> value, com.google.cloud.spanner.ValueBinder valueBinder, SpannerCustomConverter writeConverter, Class innerType) Bind an iterable value to a ValueBinder.com.google.cloud.spanner.KeyconvertToKey(Object key) Convert a given object to a Cloud Spanner key.static Class<?>static Class<?>Get the SpannerWriteConverter used to convert types into Cloud Spanner compatible types.voidwrite(Object source, MultipleValueBinder sink) voidwrite(Object source, MultipleValueBinder sink, Set<String> includeColumns) Writes an object's properties to the sink.
-
Field Details
-
singleItemTypeValueBinderMethodMap
public static final Map<Class<?>,BiFunction<com.google.cloud.spanner.ValueBinder, singleItemTypeValueBinderMethodMap?, ?>> A map of types to functions that binds them to `ValueBinder` objects.
-
-
Method Details
-
findFirstCompatibleSpannerSingleItemNativeType
-
findFirstCompatibleSpannerMultipleItemNativeType
-
write
- Specified by:
writein interfaceorg.springframework.data.convert.EntityWriter<Object,MultipleValueBinder>
-
write
Writes an object's properties to the sink.- Specified by:
writein interfaceSpannerEntityWriter- Parameters:
source- the object to writesink- the sink to which to writeincludeColumns- the columns to write. If null, then all columns are written.
-
convertToKey
Description copied from interface:SpannerEntityWriterConvert a given object to a Cloud Spanner key.- Specified by:
convertToKeyin interfaceSpannerEntityWriter- Parameters:
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.- Returns:
- the Cloud Spanner key.
-
getSpannerWriteConverter
Description copied from interface:SpannerEntityWriterGet the SpannerWriteConverter used to convert types into Cloud Spanner compatible types.- Specified by:
getSpannerWriteConverterin interfaceSpannerEntityWriter- Returns:
- a SpannerWriteConverter
-
attemptSetIterableValueOnBinder
public static boolean attemptSetIterableValueOnBinder(Iterable<Object> value, com.google.cloud.spanner.ValueBinder valueBinder, SpannerCustomConverter writeConverter, Class innerType) Bind an iterable value to a ValueBinder.- Parameters:
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.- Returns:
trueif the binding was successful.
-
attemptBindSingleValue
public static boolean attemptBindSingleValue(Object propertyValue, Class<?> propertyType, com.google.cloud.spanner.ValueBinder valueBinder, SpannerCustomConverter spannerCustomConverter) Bind a value to a ValueBinder.- Parameters:
propertyValue- the value to bind.propertyType- the type of the value to bind.valueBinder- the binder.spannerCustomConverter- the converter used to convert if necessary.- Returns:
trueif the value was bound successfully.
-