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>

public class DefaultDatastoreEntityConverter extends Object implements DatastoreEntityConverter
A class for object to entity and entity to object conversions.
Since:
1.1
  • Constructor Details

  • Method Details

    • getConversions

      public ReadWriteConversions getConversions()
      Description copied from interface: DatastoreEntityConverter
      Get the ReadWriteConversions used in this converter.
      Specified by:
      getConversions in interface DatastoreEntityConverter
      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 a Map.
      Specified by:
      readAsMap in interface DatastoreEntityConverter
      Type Parameters:
      T - the type of the key in the map
      R - 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 a Map when the map type is unknown.
      Specified by:
      readAsMap in interface DatastoreEntityConverter
      Type Parameters:
      T - the type of the key in the map
      R - 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 a DatastorePersistentEntity with support for discriminator fields.
      Specified by:
      getDiscriminationPersistentEntity in interface DatastoreEntityConverter
      Type Parameters:
      T - the type of the entity
      Parameters:
      entityClass - the entity class
      entity - the Datastore entity
      Returns:
      DatastorePersistentEntity for the entity type with support for discriminator fields.
    • read

      public <R> R read(Class<R> clazz, com.google.cloud.datastore.BaseEntity entity)
      Specified by:
      read in interface org.springframework.data.convert.EntityReader<Object,com.google.cloud.datastore.BaseEntity>
    • write

      public void write(Object source, @NonNull com.google.cloud.datastore.BaseEntity.Builder sink)
      Specified by:
      write in interface org.springframework.data.convert.EntityWriter<Object,com.google.cloud.datastore.BaseEntity.Builder>