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
ConstructorDescriptionDefaultDatastoreEntityConverter
(DatastoreMappingContext mappingContext, ObjectToKeyFactory objectToKeyFactory) DefaultDatastoreEntityConverter
(DatastoreMappingContext mappingContext, ReadWriteConversions conversions) -
Method Summary
Modifier and TypeMethodDescriptionGet theReadWriteConversions
used in this converter.<T> DatastorePersistentEntity<T>
getDiscriminationPersistentEntity
(Class<T> entityClass, com.google.cloud.datastore.BaseEntity<?> entity) Provide aDatastorePersistentEntity
with 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 aMap
when 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:DatastoreEntityConverter
Get theReadWriteConversions
used in this converter.- Specified by:
getConversions
in 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:DatastoreEntityConverter
Read the entity as aMap
.- Specified by:
readAsMap
in 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:DatastoreEntityConverter
Read the entity as aMap
when the map type is unknown.- Specified by:
readAsMap
in 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:DatastoreEntityConverter
Provide aDatastorePersistentEntity
with support for discriminator fields.- Specified by:
getDiscriminationPersistentEntity
in interfaceDatastoreEntityConverter
- Type Parameters:
T
- the type of the entity- Parameters:
entityClass
- the entity classentity
- the Datastore entity- Returns:
DatastorePersistentEntity
for the entity type with support for discriminator fields.
-
read
- Specified by:
read
in interfaceorg.springframework.data.convert.EntityReader<Object,
com.google.cloud.datastore.BaseEntity>
-
write
- Specified by:
write
in interfaceorg.springframework.data.convert.EntityWriter<Object,
com.google.cloud.datastore.BaseEntity.Builder>
-