Class MappingCosmosConverter
- java.lang.Object
-
- com.azure.spring.data.cosmos.core.convert.MappingCosmosConverter
-
- All Implemented Interfaces:
org.springframework.beans.factory.Aware,org.springframework.context.ApplicationContextAware,org.springframework.data.convert.EntityConverter<CosmosPersistentEntity<?>,CosmosPersistentProperty,Object,JsonNode>,org.springframework.data.convert.EntityReader<Object,JsonNode>,org.springframework.data.convert.EntityWriter<Object,JsonNode>
public class MappingCosmosConverter extends Object implements org.springframework.data.convert.EntityConverter<CosmosPersistentEntity<?>,CosmosPersistentProperty,Object,JsonNode>, org.springframework.context.ApplicationContextAware
A converter class between common types and cosmosItemProperties
-
-
Field Summary
Fields Modifier and Type Field Description protected org.springframework.core.convert.support.GenericConversionServiceconversionServiceGeneric conversion serviceprotected org.springframework.data.mapping.context.MappingContext<? extends CosmosPersistentEntity<?>,CosmosPersistentProperty>mappingContextMapping context
-
Constructor Summary
Constructors Constructor Description MappingCosmosConverter(org.springframework.data.mapping.context.MappingContext<? extends CosmosPersistentEntity<?>,CosmosPersistentProperty> mappingContext, ObjectMapper objectMapper)Initialization
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description org.springframework.context.ApplicationContextgetApplicationContext()To get application contextorg.springframework.core.convert.ConversionServicegetConversionService()org.springframework.data.mapping.context.MappingContext<? extends CosmosPersistentEntity<?>,CosmosPersistentProperty>getMappingContext()To get mapping context<R> Rread(Class<R> type, JsonNode jsonNode)voidsetApplicationContext(org.springframework.context.ApplicationContext applicationContext)static ObjecttoCosmosDbValue(Object fromPropertyValue)Convert a property value to the value stored in CosmosDBvoidwrite(Object source, JsonNode sink)JsonNodewriteJsonNode(Object sourceEntity)To write source entity as a cosmos item
-
-
-
Field Detail
-
mappingContext
protected final org.springframework.data.mapping.context.MappingContext<? extends CosmosPersistentEntity<?>,CosmosPersistentProperty> mappingContext
Mapping context
-
conversionService
protected org.springframework.core.convert.support.GenericConversionService conversionService
Generic conversion service
-
-
Constructor Detail
-
MappingCosmosConverter
public MappingCosmosConverter(org.springframework.data.mapping.context.MappingContext<? extends CosmosPersistentEntity<?>,CosmosPersistentProperty> mappingContext, @Qualifier("cosmosObjectMapper") ObjectMapper objectMapper)
Initialization- Parameters:
mappingContext- must not be nullobjectMapper- must not be null
-
-
Method Detail
-
writeJsonNode
public JsonNode writeJsonNode(Object sourceEntity)
To write source entity as a cosmos item- Parameters:
sourceEntity- must not be null- Returns:
- CosmosItemProperties
- Throws:
org.springframework.data.mapping.MappingException- no mapping metadata for entity typeCosmosAccessException- fail to map document value
-
getApplicationContext
public org.springframework.context.ApplicationContext getApplicationContext()
To get application context- Returns:
- ApplicationContext
-
setApplicationContext
public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
- Specified by:
setApplicationContextin interfaceorg.springframework.context.ApplicationContextAware
-
getConversionService
public org.springframework.core.convert.ConversionService getConversionService()
- Specified by:
getConversionServicein interfaceorg.springframework.data.convert.EntityConverter<CosmosPersistentEntity<?>,CosmosPersistentProperty,Object,JsonNode>
-
getMappingContext
public org.springframework.data.mapping.context.MappingContext<? extends CosmosPersistentEntity<?>,CosmosPersistentProperty> getMappingContext()
To get mapping context- Specified by:
getMappingContextin interfaceorg.springframework.data.convert.EntityConverter<CosmosPersistentEntity<?>,CosmosPersistentProperty,Object,JsonNode>- Returns:
- MappingContext
-
-