Class MappingCosmosConverter

    • Field Detail

      • 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 null
        objectMapper - must not be null
    • Method Detail

      • read

        public <R> R read​(Class<R> type,
                          JsonNode jsonNode)
        Specified by:
        read in interface org.springframework.data.convert.EntityReader<Object,​JsonNode>
      • write

        public void write​(Object source,
                          JsonNode sink)
        Specified by:
        write in interface org.springframework.data.convert.EntityWriter<Object,​JsonNode>
      • 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 type
        CosmosAccessException - 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:
        setApplicationContext in interface org.springframework.context.ApplicationContextAware
      • toCosmosDbValue

        public static Object toCosmosDbValue​(Object fromPropertyValue)
        Convert a property value to the value stored in CosmosDB
        Parameters:
        fromPropertyValue - source property value
        Returns:
        fromPropertyValue converted property value stored in CosmosDB