public class TwoStepsConversions extends Object implements ReadWriteConversions
CustomConversions, this class applies 2-step conversions.
The first step produces one of
SimpleTypeHolder's simple types. The
second step converts simple types to Datastore-native types. The second step is skipped
if the first one produces a Datastore-native type.| Constructor and Description |
|---|
TwoStepsConversions(org.springframework.data.convert.CustomConversions customConversions,
ObjectToKeyFactory objectToKeyFactory,
DatastoreMappingContext datastoreMappingContext) |
| Modifier and Type | Method and Description |
|---|---|
<T> T |
convertCollection(Object collection,
Class<?> target) |
<T> T |
convertOnRead(Object val,
Class targetCollectionType,
Class targetComponentType)
Converts a given object to an object of a target type.
|
<T> T |
convertOnRead(Object val,
EmbeddedType embeddedType,
org.springframework.data.util.TypeInformation targetTypeInformation)
Converts a given object to an object of a target type that is possibly an embedded
entity.
|
Value |
convertOnWrite(Object proppertyVal,
DatastorePersistentProperty persistentProperty)
Converts an object to a Cloud Datastore
Value; supports collections. |
Value |
convertOnWriteSingle(Object propertyVal)
Converts an object to a Cloud Datastore
Value, for non-collection objects. |
Optional<Class<?>> |
getDatastoreCompatibleType(Class inputType)
Get the Cloud Datastore-compatible native Java type that can be used to store the
given type.
|
void |
registerEntityConverter(DatastoreEntityConverter datastoreEntityConverter)
Registers
DatastoreEntityConverter to be used for embedded entities. |
public TwoStepsConversions(org.springframework.data.convert.CustomConversions customConversions,
ObjectToKeyFactory objectToKeyFactory,
DatastoreMappingContext datastoreMappingContext)
public <T> T convertOnRead(Object val, Class targetCollectionType, Class targetComponentType)
ReadWriteConversionsconvertOnRead in interface ReadWriteConversionsT - the type of the object that is produced by readingval - the value to converttargetCollectionType - the type of the collection to be converted into.
null if the property is a singular object.targetComponentType - the type of the property to convert. For collection-like
properties this refers to the individual items' type.public <T> T convertOnRead(Object val, EmbeddedType embeddedType, org.springframework.data.util.TypeInformation targetTypeInformation)
ReadWriteConversionsconvertOnRead in interface ReadWriteConversionsT - the type of the object that is produced by readingval - the value to convert.embeddedType - contains the type of embedded entity conversion should produce.targetTypeInformation - type metadata information for the desired type.public Value convertOnWrite(Object proppertyVal, DatastorePersistentProperty persistentProperty)
ReadWriteConversionsValue; supports collections.convertOnWrite in interface ReadWriteConversionsproppertyVal - the objects to convert.persistentProperty - the source field information.public Value convertOnWriteSingle(Object propertyVal)
ReadWriteConversionsValue, for non-collection objects.convertOnWriteSingle in interface ReadWriteConversionspropertyVal - the object to convert.public Optional<Class<?>> getDatastoreCompatibleType(Class inputType)
ReadWriteConversionsgetDatastoreCompatibleType in interface ReadWriteConversionsinputType - the given type to test.public void registerEntityConverter(DatastoreEntityConverter datastoreEntityConverter)
ReadWriteConversionsDatastoreEntityConverter to be used for embedded entities.registerEntityConverter in interface ReadWriteConversionsdatastoreEntityConverter - the DatastoreEntityConverter.Copyright © 2020 Pivotal Software, Inc.. All rights reserved.