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
Modifier 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 boolean
attemptBindSingleValue
(Object propertyValue, Class<?> propertyType, com.google.cloud.spanner.ValueBinder valueBinder, SpannerCustomConverter spannerCustomConverter) Bind a value to a ValueBinder.static boolean
attemptSetIterableValueOnBinder
(Iterable<Object> value, com.google.cloud.spanner.ValueBinder valueBinder, SpannerCustomConverter writeConverter, Class innerType) Bind an iterable value to a ValueBinder.com.google.cloud.spanner.Key
convertToKey
(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.void
write
(Object source, MultipleValueBinder sink) void
write
(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:
write
in interfaceorg.springframework.data.convert.EntityWriter<Object,
MultipleValueBinder>
-
write
Writes an object's properties to the sink.- Specified by:
write
in 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:SpannerEntityWriter
Convert a given object to a Cloud Spanner key.- Specified by:
convertToKey
in 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:SpannerEntityWriter
Get the SpannerWriteConverter used to convert types into Cloud Spanner compatible types.- Specified by:
getSpannerWriteConverter
in 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:
true
if 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:
true
if the value was bound successfully.
-