Class MappingRedisOMConverter

java.lang.Object
com.redis.om.spring.convert.MappingRedisOMConverter
All Implemented Interfaces:
org.springframework.beans.factory.InitializingBean, org.springframework.data.convert.EntityConverter<org.springframework.data.redis.core.mapping.RedisPersistentEntity<?>,org.springframework.data.redis.core.mapping.RedisPersistentProperty,Object,org.springframework.data.redis.core.convert.RedisData>, org.springframework.data.convert.EntityReader<Object,org.springframework.data.redis.core.convert.RedisData>, org.springframework.data.convert.EntityWriter<Object,org.springframework.data.redis.core.convert.RedisData>, org.springframework.data.redis.core.convert.RedisConverter

public class MappingRedisOMConverter extends Object implements org.springframework.data.redis.core.convert.RedisConverter, org.springframework.beans.factory.InitializingBean
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    Value object representing a binary Redis Hash/Object identifier composed of keyspace and object id in the form of keyspace:id.
    static class 
    Value object representing a Redis Hash/Object identifier composed of keyspace and object id in the form of keyspace:id.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
    MappingRedisOMConverter(org.springframework.data.redis.core.mapping.RedisMappingContext context)
    MappingRedisOMConverter(org.springframework.data.redis.core.mapping.RedisMappingContext mappingContext, org.springframework.data.redis.core.convert.ReferenceResolver referenceResolver)
    Creates new MappingRedisOMConverter and defaults RedisMappingContext when null.
    MappingRedisOMConverter(org.springframework.data.redis.core.mapping.RedisMappingContext mappingContext, org.springframework.data.redis.core.convert.ReferenceResolver referenceResolver, org.springframework.data.redis.core.convert.RedisTypeMapper typeMapper)
    Creates new MappingRedisOMConverter and defaults RedisMappingContext when null.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
     
    <T> T
    fromBytes(byte[] source, Class<T> type)
    Convert given binary representation to desired target type using the underlying ConversionService.
    org.springframework.core.convert.ConversionService
     
    org.springframework.data.redis.core.convert.IndexResolver
     
    org.springframework.data.redis.core.mapping.RedisMappingContext
     
    <R> R
    read(Class<R> type, org.springframework.data.redis.core.convert.RedisData source)
     
    protected Object
    readProperty(Class<?> entityClass, String path, org.springframework.data.redis.core.convert.RedisData source, org.springframework.data.redis.core.mapping.RedisPersistentProperty persistentProperty)
     
    void
    setCustomConversions(org.springframework.data.convert.CustomConversions customConversions)
    Set CustomConversions to be applied.
    void
    setReferenceResolver(org.springframework.data.redis.core.convert.ReferenceResolver referenceResolver)
     
    byte[]
    toBytes(Object source)
    Convert given source to binary representation using the underlying ConversionService.
    void
    write(Object source, org.springframework.data.redis.core.convert.RedisData sink)
     
    protected void
    writePartialUpdate(org.springframework.data.redis.core.PartialUpdate<?> update, org.springframework.data.redis.core.convert.RedisData sink)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • MappingRedisOMConverter

      public MappingRedisOMConverter()
    • MappingRedisOMConverter

      public MappingRedisOMConverter(org.springframework.data.redis.core.mapping.RedisMappingContext context)
      Parameters:
      context - can be null.
    • MappingRedisOMConverter

      public MappingRedisOMConverter(@Nullable org.springframework.data.redis.core.mapping.RedisMappingContext mappingContext, @Nullable org.springframework.data.redis.core.convert.ReferenceResolver referenceResolver)
      Creates new MappingRedisOMConverter and defaults RedisMappingContext when null.
      Parameters:
      mappingContext - can be null.
      referenceResolver - can be not be null.
    • MappingRedisOMConverter

      public MappingRedisOMConverter(@Nullable org.springframework.data.redis.core.mapping.RedisMappingContext mappingContext, @Nullable org.springframework.data.redis.core.convert.ReferenceResolver referenceResolver, @Nullable org.springframework.data.redis.core.convert.RedisTypeMapper typeMapper)
      Creates new MappingRedisOMConverter and defaults RedisMappingContext when null.
      Parameters:
      mappingContext - can be null.
      referenceResolver - can be null.
      typeMapper - can be null.
  • Method Details

    • read

      public <R> R read(Class<R> type, org.springframework.data.redis.core.convert.RedisData source)
      Specified by:
      read in interface org.springframework.data.convert.EntityReader<Object,org.springframework.data.redis.core.convert.RedisData>
    • readProperty

      @Nullable protected Object readProperty(Class<?> entityClass, String path, org.springframework.data.redis.core.convert.RedisData source, org.springframework.data.redis.core.mapping.RedisPersistentProperty persistentProperty)
    • write

      public void write(Object source, org.springframework.data.redis.core.convert.RedisData sink)
      Specified by:
      write in interface org.springframework.data.convert.EntityWriter<Object,org.springframework.data.redis.core.convert.RedisData>
    • writePartialUpdate

      protected void writePartialUpdate(org.springframework.data.redis.core.PartialUpdate<?> update, org.springframework.data.redis.core.convert.RedisData sink)
    • toBytes

      public byte[] toBytes(Object source)
      Convert given source to binary representation using the underlying ConversionService.
      Parameters:
      source - the source object
      Returns:
      a byte array representation
      Throws:
      org.springframework.core.convert.ConverterNotFoundException - if a specific converter cannot be found
    • fromBytes

      public <T> T fromBytes(byte[] source, Class<T> type)
      Convert given binary representation to desired target type using the underlying ConversionService.
      Type Parameters:
      T - expected type of the source object
      Parameters:
      source - the source object
      type - the class to cast the object to
      Returns:
      the target object
      Throws:
      org.springframework.core.convert.ConverterNotFoundException - if a specific converter cannot be found
    • setReferenceResolver

      public void setReferenceResolver(org.springframework.data.redis.core.convert.ReferenceResolver referenceResolver)
    • setCustomConversions

      public void setCustomConversions(@Nullable org.springframework.data.convert.CustomConversions customConversions)
      Set CustomConversions to be applied.
      Parameters:
      customConversions - custom convertions to be added to the pipeline
    • getMappingContext

      public org.springframework.data.redis.core.mapping.RedisMappingContext getMappingContext()
      Specified by:
      getMappingContext in interface org.springframework.data.convert.EntityConverter<org.springframework.data.redis.core.mapping.RedisPersistentEntity<?>,org.springframework.data.redis.core.mapping.RedisPersistentProperty,Object,org.springframework.data.redis.core.convert.RedisData>
      Specified by:
      getMappingContext in interface org.springframework.data.redis.core.convert.RedisConverter
    • getIndexResolver

      @Nullable public org.springframework.data.redis.core.convert.IndexResolver getIndexResolver()
      Specified by:
      getIndexResolver in interface org.springframework.data.redis.core.convert.RedisConverter
    • getConversionService

      public org.springframework.core.convert.ConversionService getConversionService()
      Specified by:
      getConversionService in interface org.springframework.data.convert.EntityConverter<org.springframework.data.redis.core.mapping.RedisPersistentEntity<?>,org.springframework.data.redis.core.mapping.RedisPersistentProperty,Object,org.springframework.data.redis.core.convert.RedisData>
    • afterPropertiesSet

      public void afterPropertiesSet()
      Specified by:
      afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean