/*
* Copyright 2014 Red Hat, Inc.
*
* Red Hat licenses this file to you under the Apache License, version 2.0
* (the "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*/
package io.vertx.rxjava.redis.client;
import java.util.Map;
import rx.Observable;
import rx.Single;
import java.nio.charset.Charset;
import java.util.Set;
import io.vertx.redis.client.ResponseType;
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.
NOTE: This class has been automatically generated from the original
non RX-ified interface using Vert.x codegen. /**
* The response received from the REDIS server. Redis responses can have several representations:
*
* <ul>
* <li>simple string - C string</li>
* <li>integer - 64bit integer value</li>
* <li>bulk - byte array</li>
* <li>multi - list</li>
* </ul>
*
* 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.
*
* <p/>
* NOTE: This class has been automatically generated from the {@link io.vertx.redis.client.Response original} non RX-ified interface using Vert.x codegen.
*/
@io.vertx.lang.rx.RxGen(io.vertx.redis.client.Response.class)
public class Response implements java.lang.Iterable<io.vertx.rxjava.redis.client.Response> {
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Response that = (Response) o;
return delegate.equals(that.delegate);
}
@Override
public int hashCode() {
return delegate.hashCode();
}
@Override
public java.util.Iterator<io.vertx.rxjava.redis.client.Response> iterator() {
java.util.function.Function<io.vertx.redis.client.Response, io.vertx.rxjava.redis.client.Response> conv = io.vertx.rxjava.redis.client.Response::newInstance;
return new io.vertx.lang.rx.MappingIterator<>(delegate.iterator(), conv);
}
public static final io.vertx.lang.rx.TypeArg<Response> __TYPE_ARG = new io.vertx.lang.rx.TypeArg<>( obj -> new Response((io.vertx.redis.client.Response) obj),
Response::getDelegate
);
private final io.vertx.redis.client.Response delegate;
public Response(io.vertx.redis.client.Response delegate) {
this.delegate = delegate;
}
public io.vertx.redis.client.Response getDelegate() {
return delegate;
}
The response return type.
Returns: the type.
/**
* The response return type.
* @return the type.
*/
public ResponseType type() {
ResponseType ret = delegate.type();
return ret;
}
Get this response as a String.
Returns: string value
/**
* Get this response as a String.
* @return string value
*/
public String toString() {
String ret = delegate.toString();
return ret;
}
Get this response as a Long.
Returns: long value.
/**
* Get this response as a Long.
* @return long value.
*/
public Long toLong() {
Long ret = delegate.toLong();
return ret;
}
Get this response as a Integer.
Returns: int value.
/**
* Get this response as a Integer.
* @return int value.
*/
public Integer toInteger() {
Integer ret = delegate.toInteger();
return ret;
}
Get this response as a Short.
Returns: short value.
/**
* Get this response as a Short.
* @return short value.
*/
public Short toShort() {
Short ret = delegate.toShort();
return ret;
}
Get this response as a Byte.
Returns: byte value.
/**
* Get this response as a Byte.
* @return byte value.
*/
public Byte toByte() {
Byte ret = delegate.toByte();
return ret;
}
Get this response as a Boolean.
Returns: boolean value.
/**
* Get this response as a Boolean.
* @return boolean value.
*/
public Boolean toBoolean() {
Boolean ret = delegate.toBoolean();
return ret;
}
Get this response as Buffer.
Returns: buffer value.
/**
* Get this response as Buffer.
* @return buffer value.
*/
public io.vertx.rxjava.core.buffer.Buffer toBuffer() {
io.vertx.rxjava.core.buffer.Buffer ret = io.vertx.rxjava.core.buffer.Buffer.newInstance(delegate.toBuffer());
return ret;
}
Get this multi response value at a numerical index.
Params: - index – the required index.
Returns: Response value.
/**
* Get this multi response value at a numerical index.
* @param index the required index.
* @return Response value.
*/
public io.vertx.rxjava.redis.client.Response get(int index) {
io.vertx.rxjava.redis.client.Response ret = io.vertx.rxjava.redis.client.Response.newInstance(delegate.get(index));
return ret;
}
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.
Params: - key – the required key.
Returns: Response value.
/**
* 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.
* @param key the required key.
* @return Response value.
*/
public io.vertx.rxjava.redis.client.Response get(String key) {
io.vertx.rxjava.redis.client.Response ret = io.vertx.rxjava.redis.client.Response.newInstance(delegate.get(key));
return ret;
}
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.
/**
* 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.
* @return the set of keys.
*/
public Set<String> getKeys() {
Set<String> ret = delegate.getKeys();
return ret;
}
Get this size of this multi response.
Returns: the size of the multi.
/**
* Get this size of this multi response.
* @return the size of the multi.
*/
public int size() {
int ret = delegate.size();
return ret;
}
Get this response as a String encoded with the given charset.
Params: - encoding –
Returns: String value.
/**
* Get this response as a String encoded with the given charset.
* @param encoding
* @return String value.
*/
public String toString(Charset encoding) {
String ret = delegate.toString(encoding);
return ret;
}
Get this response as a byte[].
Returns: byte[] value.
/**
* Get this response as a byte[].
* @return byte[] value.
*/
public byte[] toBytes() {
byte[] ret = delegate.toBytes();
return ret;
}
public static Response newInstance(io.vertx.redis.client.Response arg) {
return arg != null ? new Response(arg) : null;
}
}