Class Converters
java.lang.Object
org.springframework.data.redis.connection.convert.Converters
- Direct Known Subclasses:
- LettuceConverters
Common type converters.
- Author:
- Jennifer Hickey, Thomas Darimont, Mark Paluch, Christoph Strobl, daihuabin, John Blum, Sorokin Evgeniy, Marcin Grzejszczak
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionstatic <V> Converter<GeoResults<RedisGeoCommands.GeoLocation<byte[]>>,GeoResults<RedisGeoCommands.GeoLocation<V>>> deserializingGeoResultsConverter(RedisSerializer<V> serializer) Convertercapable of deserializingGeoResults.distanceConverterForMetric(Metric metric) static <K,V> Map.Entry<K, V> entryOf(K key, V value) static <T> Converter<T,T> Returns aConverterthat always returns its input argument.static Converter<List<String>,Properties> Returns a converter to convert array outputs with key-value sequences (such as produced byCONFIG GET) from aListtoProperties.static <K,V> Converter<Map<K, V>, Properties> Returns a converter to convert fromMaptoProperties.static longmillisecondsToTimeUnit(long milliseconds, TimeUnit targetUnit) Convertsmillisecondsto the givenTimeUnit.millisecondsToTimeUnit(TimeUnit timeUnit) static <T> TParse a rather generic Redis response, such as a list of something into a meaningful structure applying best effort conversion ofbyte[]andByteBuffer.static ObjectParse a rather generic Redis response, such as a list of something into a meaningful structure applying best effort conversion ofbyte[]andByteBufferbased on the sourcePath and a typeHintMapstatic DurationsecondsToDuration(Long seconds) Convert the given nullable seconds to aDurationor null.static longsecondsToTimeUnit(long seconds, TimeUnit targetUnit) Convertssecondsto the givenTimeUnit.secondsToTimeUnit(TimeUnit timeUnit) static BooleanstringToBoolean(String source) static Converter<String,Properties> static byte[]static Booleanprotected static RedisClusterNodetoClusterNode(String clusterNodesLine) Converts the result of a single line ofCLUSTER NODESinto aRedisClusterNode.static DataTypetoDataType(String source) static PropertiestoProperties(String source) static PropertiestoProperties(List<String> input) Converts array outputs with key-value sequences (such as produced byCONFIG GET) from aListtoProperties.static PropertiestoProperties(Map<?, ?> source) static Set<RedisClusterNode>toSetOfRedisClusterNodes(String clusterNodes) Converts the result ofCLUSTER NODESintoRedisClusterNodes.static Set<RedisClusterNode>toSetOfRedisClusterNodes(Collection<String> lines) Converts lines from the result ofCLUSTER NODESintoRedisClusterNodes.static LongtoTimeMillis(String seconds, String microseconds) Returns the timestamp constructed from the givensecondsandmicroseconds.static LongtoTimeMillis(String seconds, String microseconds, TimeUnit unit) Returns the timestamp constructed from the givensecondsandmicroseconds.
- 
Constructor Details- 
Converterspublic Converters()
 
- 
- 
Method Details- 
identityConverterReturns aConverterthat always returns its input argument.- Type Parameters:
- T- the type of the input and output objects to the function
- Returns:
- a function that always returns its input argument
- Since:
- 2.5
 
- 
stringToBoolean
- 
stringToBooleanConverter
- 
stringToProps
- 
longToBoolean
- 
stringToDataType
- 
toProperties
- 
toProperties
- 
toBoolean
- 
toDataType
- 
toBit
- 
toClusterNodeConverts the result of a single line ofCLUSTER NODESinto aRedisClusterNode.- Parameters:
- clusterNodesLine-
- Returns:
- Since:
- 1.7
 
- 
toSetOfRedisClusterNodesConverts lines from the result ofCLUSTER NODESintoRedisClusterNodes.- Parameters:
- lines-
- Returns:
- Since:
- 1.7
 
- 
toSetOfRedisClusterNodesConverts the result ofCLUSTER NODESintoRedisClusterNodes.- Parameters:
- clusterNodes-
- Returns:
- Since:
- 1.7
 
- 
toObjects
- 
toTimeMillisReturns the timestamp constructed from the givensecondsandmicroseconds.- Parameters:
- seconds- server time in seconds
- microseconds- elapsed microseconds in current second
- Returns:
 
- 
toTimeMillisReturns the timestamp constructed from the givensecondsandmicroseconds.- Parameters:
- seconds- server time in seconds.
- microseconds- elapsed microseconds in current second.
- unit- target unit.
- Returns:
- Since:
- 2.5
 
- 
secondsToTimeUnitConvertssecondsto the givenTimeUnit.- Parameters:
- seconds-
- targetUnit- must not be null.
- Returns:
- Since:
- 1.8
 
- 
secondsToTimeUnit- Parameters:
- timeUnit- muist not be null.
- Returns:
- Since:
- 1.8
 
- 
millisecondsToTimeUnitConvertsmillisecondsto the givenTimeUnit.- Parameters:
- milliseconds-
- targetUnit- must not be null.
- Returns:
- Since:
- 1.8
 
- 
millisecondsToTimeUnit- Parameters:
- timeUnit- must not be null.
- Returns:
- Since:
- 1.8
 
- 
deserializingGeoResultsConverterpublic static <V> Converter<GeoResults<RedisGeoCommands.GeoLocation<byte[]>>,GeoResults<RedisGeoCommands.GeoLocation<V>>> deserializingGeoResultsConverter(RedisSerializer<V> serializer) Convertercapable of deserializingGeoResults.- Parameters:
- serializer-
- Returns:
- Since:
- 1.8
 
- 
distanceConverterForMetric- Parameters:
- metric-
- Returns:
- Since:
- 1.8
 
- 
toPropertiesConverts array outputs with key-value sequences (such as produced byCONFIG GET) from aListtoProperties.- Parameters:
- input- must not be null.
- Returns:
- the mapped result.
- Since:
- 2.0
 
- 
listToPropertiesConverterReturns a converter to convert array outputs with key-value sequences (such as produced byCONFIG GET) from aListtoProperties.- Returns:
- the converter.
- Since:
- 2.0
 
- 
mapToPropertiesConverterReturns a converter to convert fromMaptoProperties.- Returns:
- the converter.
- Since:
- 2.0
 
- 
secondsToDurationConvert the given nullable seconds to aDurationor null.- Parameters:
- seconds- can be null.
- Returns:
- given seconds as Durationor null.
- Since:
- 2.1
 
- 
parseParse a rather generic Redis response, such as a list of something into a meaningful structure applying best effort conversion ofbyte[]andByteBuffer.
- 
parseParse a rather generic Redis response, such as a list of something into a meaningful structure applying best effort conversion ofbyte[]andByteBufferbased on the sourcePath and a typeHintMap- Parameters:
- source- the source to parse
- sourcePath- the current path (use "root", for level 0).
- typeHintMap- source path to target type hints allowing wildcards (*).
- Returns:
- Since:
- 2.3
 
- 
entryOf- Type Parameters:
- K-
- V-
- Parameters:
- key-
- value-
- Returns:
- Since:
- 2.6
 
 
-