RMapAsync interface added. #186
parent
0e0e1c1b3f
commit
68a1c014c2
@ -0,0 +1,40 @@
|
||||
package org.redisson.client.protocol.convertor;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
public class NumberConvertor extends SingleConvertor<Object> {
|
||||
|
||||
private Class<?> resultClass;
|
||||
|
||||
public NumberConvertor(Class<?> resultClass) {
|
||||
super();
|
||||
this.resultClass = resultClass;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object convert(Object result) {
|
||||
String res = (String) result;
|
||||
if (resultClass.isAssignableFrom(Long.class)) {
|
||||
Object obj = Long.parseLong(res);
|
||||
return obj;
|
||||
}
|
||||
if (resultClass.isAssignableFrom(Integer.class)) {
|
||||
Object obj = Integer.parseInt(res);
|
||||
return obj;
|
||||
}
|
||||
if (resultClass.isAssignableFrom(Float.class)) {
|
||||
Object obj = Float.parseFloat(res);
|
||||
return obj;
|
||||
}
|
||||
if (resultClass.isAssignableFrom(Double.class)) {
|
||||
Object obj = Double.parseDouble(res);
|
||||
return obj;
|
||||
}
|
||||
if (resultClass.isAssignableFrom(BigDecimal.class)) {
|
||||
Object obj = new BigDecimal(res);
|
||||
return obj;
|
||||
}
|
||||
throw new IllegalStateException("Wrong value type!");
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
/**
|
||||
* Copyright 2014 Nikita Koksharov, Nickolay Borbit
|
||||
*
|
||||
* Licensed 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 org.redisson.client.protocol.decoder;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
public class ObjectSetReplayDecoder implements MultiDecoder<Set<Object>> {
|
||||
|
||||
@Override
|
||||
public Object decode(ByteBuf buf) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Object> decode(List<Object> parts) {
|
||||
return new HashSet<Object>(parts);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isApplicable(int paramNum) {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,84 @@
|
||||
/**
|
||||
* Copyright 2014 Nikita Koksharov, Nickolay Borbit
|
||||
*
|
||||
* Licensed 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 org.redisson.core;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
|
||||
import io.netty.util.concurrent.Future;
|
||||
|
||||
/**
|
||||
* Async map functions
|
||||
*
|
||||
* @author Nikita Koksharov
|
||||
*
|
||||
* @param <K> key
|
||||
* @param <V> value
|
||||
*/
|
||||
public interface RMapAsync<K, V> extends RExpirableAsync {
|
||||
|
||||
Future<V> addAndGetAsync(K key, Number value);
|
||||
|
||||
Future<Collection<V>> valuesAsync();
|
||||
|
||||
Future<Set<K>> keySetAsync();
|
||||
|
||||
Future<Boolean> containsValueAsync(Object value);
|
||||
|
||||
Future<Boolean> containsKeyAsync(Object key);
|
||||
|
||||
Future<Integer> sizeAsync();
|
||||
|
||||
/**
|
||||
* Removes <code>keys</code> from map by one operation in async manner
|
||||
*
|
||||
* Works faster than <code>RMap.removeAsync</code> but not returning
|
||||
* the value associated with <code>key</code>
|
||||
*
|
||||
* @param keys
|
||||
* @return the number of keys that were removed from the hash, not including specified but non existing keys
|
||||
*/
|
||||
Future<Long> fastRemoveAsync(K ... keys);
|
||||
|
||||
/**
|
||||
* Associates the specified <code>value</code> with the specified <code>key</code>
|
||||
* in async manner.
|
||||
*
|
||||
* Works faster than <code>RMap.putAsync</code> but not returning
|
||||
* the previous value associated with <code>key</code>
|
||||
*
|
||||
* @param key
|
||||
* @param value
|
||||
* @return <code>true</code> if key is a new key in the hash and value was set.
|
||||
* <code>false</code> if key already exists in the hash and the value was updated.
|
||||
*/
|
||||
Future<Boolean> fastPutAsync(K key, V value);
|
||||
|
||||
Future<V> getAsync(K key);
|
||||
|
||||
Future<V> putAsync(K key, V value);
|
||||
|
||||
Future<V> removeAsync(K key);
|
||||
|
||||
Future<V> replaceAsync(K key, V value);
|
||||
|
||||
Future<Boolean> replaceAsync(K key, V oldValue, V newValue);
|
||||
|
||||
Future<Long> removeAsync(Object key, Object value);
|
||||
|
||||
Future<V> putIfAbsentAsync(K key, V value);
|
||||
|
||||
}
|
Loading…
Reference in New Issue