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 Summary
Constructors -
Method Summary
Modifier 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> 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.Deprecated, for removal: This API element is subject to removal in a future version.static <K,V> Converter <Map<K, V>, Properties> Deprecated, for removal: This API element is subject to removal in a future version.since 4.2, usetoProperties(Map)through method-reference or lambda syntax.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 typeHintMapsecondsToDuration(@Nullable 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) Alias fortoBoolean(String).Deprecated, for removal: This API element is subject to removal in a future version.since 4.2, usetoBoolean(String)through method-reference or lambda syntax.Deprecated, for removal: This API element is subject to removal in a future version.since 4.2, usetoDataType(String)through method-reference or lambda syntax.static Converter<String, Properties> Deprecated, for removal: This API element is subject to removal in a future version.since 4.2, usetoProperties(String)through method-reference or lambda syntax.static byte[]Render abooleanas bit command argument,1for true and0for false.static booleanInterpret a Redis integer reply asboolean.static BooleanInterpret a Redis status reply as success.protected static RedisClusterNodetoClusterNode(String clusterNodesLine) Converts the result of a single line ofCLUSTER NODESinto aRedisClusterNode.static DataTypetoDataType(String source) Resolve theDataTypefor a RedisTYPEreply.FlattenTuples into a list of alternating score and value entries as expected byZADD.static PropertiestoProperties(String source) Parse RedisINFOoutput toProperties.static PropertiestoProperties(List<String> input) Converts array outputs with key-value sequences (such as produced byCONFIG GET) from aListtoProperties.static PropertiestoProperties(Map<?, ?> source) Copy all entries ofsourceinto a newPropertiesinstance.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
-
Converters
public Converters()
-
-
Method Details
-
identityConverter
-
stringToBooleanConverter
@Deprecated(since="4.2", forRemoval=true) public static Converter<String,Boolean> stringToBooleanConverter()Deprecated, for removal: This API element is subject to removal in a future version.since 4.2, usetoBoolean(String)through method-reference or lambda syntax. -
stringToProps
@Deprecated(since="4.2", forRemoval=true) public static Converter<String, Properties> stringToProps()Deprecated, for removal: This API element is subject to removal in a future version.since 4.2, usetoProperties(String)through method-reference or lambda syntax. -
longToBoolean
Deprecated, for removal: This API element is subject to removal in a future version.since 4.2, usetoBoolean(Long)through method-reference or lambda syntax. -
stringToDataType
@Deprecated(since="4.2", forRemoval=true) public static Converter<String,DataType> stringToDataType()Deprecated, for removal: This API element is subject to removal in a future version.since 4.2, usetoDataType(String)through method-reference or lambda syntax. -
toBit
Render abooleanas bit command argument,1for true and0for false. -
toBoolean
-
toBoolean
-
stringToBoolean
Alias fortoBoolean(String). -
toDataType
Resolve theDataTypefor a RedisTYPEreply.- Throws:
IllegalArgumentException- if the reply does not name a knownDataType.
-
toProperties
Parse RedisINFOoutput toProperties. UnlikeProperties.load(Reader), this converter does not interpret escape sequences so that e.g. Windows-style backslashes are preserved verbatim.- Parameters:
source- the INFO command response.- Returns:
- the response parsed as
Properties.
-
toProperties
Copy all entries ofsourceinto a newPropertiesinstance. Entries are copied as-is, so onlyStringkeys and values are accessible throughProperties.getProperty(String). -
toClusterNode
Converts the result of a single line ofCLUSTER NODESinto aRedisClusterNode.- Parameters:
clusterNodesLine-- Returns:
- Since:
- 1.7
-
toSetOfRedisClusterNodes
Converts lines from the result ofCLUSTER NODESintoRedisClusterNodes.- Parameters:
lines-- Returns:
- Since:
- 1.7
-
toSetOfRedisClusterNodes
Converts the result ofCLUSTER NODESintoRedisClusterNodes.- Parameters:
clusterNodes-- Returns:
- Since:
- 1.7
-
toObjects
-
toTimeMillis
-
toTimeMillis
-
secondsToTimeUnit
-
secondsToTimeUnit
-
millisecondsToTimeUnit
-
millisecondsToTimeUnit
-
deserializingGeoResultsConverter
public 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
-
toProperties
Converts 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
-
listToPropertiesConverter
Returns a converter to convert array outputs with key-value sequences (such as produced byCONFIG GET) from aListtoProperties.- Returns:
- the converter.
- Since:
- 2.0
-
mapToPropertiesConverter
@Deprecated(since="4.2", forRemoval=true) public static <K,V> Converter<Map<K,V>, Properties> mapToPropertiesConverter()Deprecated, for removal: This API element is subject to removal in a future version.since 4.2, usetoProperties(Map)through method-reference or lambda syntax.Returns a converter to convert fromMaptoProperties.- Returns:
- the converter.
- Since:
- 2.0
-
secondsToDuration
-
parse
Parse a rather generic Redis response, such as a list of something into a meaningful structure applying best effort conversion ofbyte[]andByteBuffer. -
parse
Parse 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 parsesourcePath- the current path (use "root", for level 0).typeHintMap- source path to target type hints allowing wildcards (*).- Returns:
- Since:
- 2.3
-
entryOf
-
toBoolean(Long)through method-reference or lambda syntax.