Package io.vertx.redis.client
Interface Response
-
public interface Response extends Iterable<Response>
The response received from the REDIS server. Redis responses can have several representations:- simple string - C string
- integer - 64bit integer value
- bulk - byte array
- multi - list
Due to the dynamic nature the response object will try to cast the received response to the desired type. A special case should be noted that multi responses are also handled by the response object as it implements the iterable interface. So in this case constructs like for loops on the response will give you access to the underlying elements.
- Author:
- Paulo Lopes
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default Map<String,Response>
attributes()
RESP3 responses may include attributesdefault boolean
containsKey(String key)
Does this multi response contains a string key.default String
format()
RESP3 Verbatim Bulk message include a 3 character format.default Response
get(int index)
Get this multi response value at a numerical index.default Response
get(String key)
Get this multi response value at a string key.default Set<String>
getKeys()
Get this multi response keys from a hash.default boolean
isArray()
Returns whether this multi response is an array and henceget(int)
can be called.default boolean
isMap()
Returns whether this multi response is a map and henceget(String)
,containsKey(String)
andgetKeys()
may be called.default Iterator<Response>
iterator()
Return an iterator so it can be iterated using the foreach construct.default int
size()
Get this size of this multi response.default java.util.stream.Stream<Response>
stream()
Return a stream of responses based on the iterable of this object.default BigInteger
toBigInteger()
Get this response as a BigInteger.default Boolean
toBoolean()
Get this response as a Boolean.default Buffer
toBuffer()
Get this response as Buffer.default Byte
toByte()
Get this response as a Byte.default byte[]
toBytes()
Get this response as a byte[].default Double
toDouble()
Get this response as a Double.default Float
toFloat()
Get this response as a Float.default Integer
toInteger()
Get this response as a Integer.default Long
toLong()
Get this response as a Long.default Number
toNumber()
Get this response as a Number.default Short
toShort()
Get this response as a Short.String
toString()
Get this response as a String.default String
toString(Charset encoding)
Get this response as a String encoded with the given charset.ResponseType
type()
The response return type.-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Method Detail
-
type
ResponseType type()
The response return type.- Returns:
- the type.
-
attributes
default Map<String,Response> attributes()
RESP3 responses may include attributes- Returns:
- the a key value map of attributes to this response.
-
toString
String toString()
Get this response as a String.
-
format
default String format()
RESP3 Verbatim Bulk message include a 3 character format.
-
toNumber
default Number toNumber()
Get this response as a Number. In contrast to other numeric getters, this will not perform any conversion if the underlying type is not numeric.- Returns:
- number value
-
toDouble
default Double toDouble()
Get this response as a Double.- Returns:
- double value.
-
toFloat
default Float toFloat()
Get this response as a Float.- Returns:
- double value.
-
toBigInteger
default BigInteger toBigInteger()
Get this response as a BigInteger.- Returns:
- long value.
-
toLong
default Long toLong()
Get this response as a Long.- Returns:
- long value.
-
toInteger
default Integer toInteger()
Get this response as a Integer.- Returns:
- int value.
-
toShort
default Short toShort()
Get this response as a Short.- Returns:
- short value.
-
toByte
default Byte toByte()
Get this response as a Byte.- Returns:
- byte value.
-
toBoolean
default Boolean toBoolean()
Get this response as a Boolean.- Returns:
- boolean value.
-
toString
default String toString(Charset encoding)
Get this response as a String encoded with the given charset.- Returns:
- String value.
-
toBuffer
default Buffer toBuffer()
Get this response as Buffer.- Returns:
- buffer value.
-
toBytes
default byte[] toBytes()
Get this response as a byte[].- Returns:
- byte[] value.
-
get
default Response get(int index)
Get this multi response value at a numerical index.- Parameters:
index
- the required index.- Returns:
- Response value.
-
get
default Response get(String key)
Get this multi response value at a string key. Note that REDIS does not support strings as keys but by convention it encodes hashes in lists where index i is the key, and index i+1 is the value.- Parameters:
key
- the required key.- Returns:
- Response value.
-
containsKey
default boolean containsKey(String key)
Does this multi response contains a string key. Note that REDIS does not support strings as keys but by convention it encodes hashes in lists where index i is the key, and index i+1 is the value.- Parameters:
key
- the required key.- Returns:
- Response value.
-
getKeys
default Set<String> getKeys()
Get this multi response keys from a hash. Note that REDIS does not support strings as keys but by convention it encodes hashes in lists where index i is the key, and index i+1 is the value.- Returns:
- the set of keys.
-
size
default int size()
Get this size of this multi response.- Returns:
- the size of the multi.
-
isArray
default boolean isArray()
Returns whether this multi response is an array and henceget(int)
can be called.Returns
true
also forResponseType.PUSH
andResponseType.ATTRIBUTE
.- Returns:
- whether this multi response is an array
-
isMap
default boolean isMap()
Returns whether this multi response is a map and henceget(String)
,containsKey(String)
andgetKeys()
may be called.Returns
true
also forResponseType.ATTRIBUTE
.- Returns:
- whether this multi response is a map
-
iterator
default Iterator<Response> iterator()
Return an iterator so it can be iterated using the foreach construct.
-
stream
default java.util.stream.Stream<Response> stream()
Return a stream of responses based on the iterable of this object.- Returns:
- a stream of response
-
-