Class DefaultDatastoreEntityConverter
java.lang.Object
com.google.cloud.spring.data.datastore.core.convert.DefaultDatastoreEntityConverter
- All Implemented Interfaces:
DatastoreEntityConverter,org.springframework.data.convert.EntityReader<Object,,com.google.cloud.datastore.BaseEntity> org.springframework.data.convert.EntityWriter<Object,com.google.cloud.datastore.BaseEntity.Builder>
A class for object to entity and entity to object conversions.
- Since:
- 1.1
-
Constructor Summary
ConstructorsConstructorDescriptionDefaultDatastoreEntityConverter(DatastoreMappingContext mappingContext, ObjectToKeyFactory objectToKeyFactory) DefaultDatastoreEntityConverter(DatastoreMappingContext mappingContext, ReadWriteConversions conversions) -
Method Summary
Modifier and TypeMethodDescriptionGet theReadWriteConversionsused in this converter.<T> DatastorePersistentEntity<T>getDiscriminationPersistentEntity(Class<T> entityClass, com.google.cloud.datastore.BaseEntity<?> entity) Provide aDatastorePersistentEntitywith support for discriminator fields.<R> R<T,R> Map<T, R> readAsMap(com.google.cloud.datastore.BaseEntity entity, org.springframework.data.util.TypeInformation mapTypeInformation) Read the entity as aMap.<T,R> Map<T, R> readAsMap(Class<T> keyType, org.springframework.data.util.TypeInformation<R> componentType, com.google.cloud.datastore.BaseEntity entity) Read the entity as aMapwhen the map type is unknown.void
-
Constructor Details
-
DefaultDatastoreEntityConverter
public DefaultDatastoreEntityConverter(DatastoreMappingContext mappingContext, ObjectToKeyFactory objectToKeyFactory) -
DefaultDatastoreEntityConverter
public DefaultDatastoreEntityConverter(DatastoreMappingContext mappingContext, ReadWriteConversions conversions)
-
-
Method Details
-
getConversions
Description copied from interface:DatastoreEntityConverterGet theReadWriteConversionsused in this converter.- Specified by:
getConversionsin interfaceDatastoreEntityConverter- Returns:
- the conversions used.
-
readAsMap
public <T,R> Map<T,R> readAsMap(com.google.cloud.datastore.BaseEntity entity, org.springframework.data.util.TypeInformation mapTypeInformation) Description copied from interface:DatastoreEntityConverterRead the entity as aMap.- Specified by:
readAsMapin interfaceDatastoreEntityConverter- Type Parameters:
T- the type of the key in the mapR- the type of the value in the map- Parameters:
entity- the entity from Cloud Datastore.mapTypeInformation- the actual type of the map- Returns:
- a Map where the key values are the field names and the values the field values.
-
readAsMap
public <T,R> Map<T,R> readAsMap(Class<T> keyType, org.springframework.data.util.TypeInformation<R> componentType, com.google.cloud.datastore.BaseEntity entity) Description copied from interface:DatastoreEntityConverterRead the entity as aMapwhen the map type is unknown.- Specified by:
readAsMapin interfaceDatastoreEntityConverter- Type Parameters:
T- the type of the key in the mapR- the type of the value in the map- Parameters:
keyType- the key type of the map to be read.componentType- the value type of the map, into which each field value will be converted.entity- the entity from Cloud Datastore.- Returns:
- a Map where the key values are the field names and the values the field values.
-
getDiscriminationPersistentEntity
public <T> DatastorePersistentEntity<T> getDiscriminationPersistentEntity(Class<T> entityClass, com.google.cloud.datastore.BaseEntity<?> entity) Description copied from interface:DatastoreEntityConverterProvide aDatastorePersistentEntitywith support for discriminator fields.- Specified by:
getDiscriminationPersistentEntityin interfaceDatastoreEntityConverter- Type Parameters:
T- the type of the entity- Parameters:
entityClass- the entity classentity- the Datastore entity- Returns:
DatastorePersistentEntityfor the entity type with support for discriminator fields.
-
read
- Specified by:
readin interfaceorg.springframework.data.convert.EntityReader<Object,com.google.cloud.datastore.BaseEntity>
-
write
- Specified by:
writein interfaceorg.springframework.data.convert.EntityWriter<Object,com.google.cloud.datastore.BaseEntity.Builder>
-