com.hazelcast.cache.impl
Class CacheProxyUtil

java.lang.Object
  extended by com.hazelcast.cache.impl.CacheProxyUtil

public final class CacheProxyUtil
extends Object

Static util methods for ICache implementations.

See Also:
CacheProxy

Field Summary
static int AWAIT_COMPLETION_TIMEOUT_SECONDS
           
 
Method Summary
protected static int getPartitionId(NodeEngine nodeEngine, Data key)
           
static
<K> void
validateConfiguredKeyType(Class<K> keyType, K key)
          Validates the key with key type.
static
<K> void
validateConfiguredTypes(CacheConfig cacheConfig, K key)
          Validates that the configured key matches the provided key.
static
<K,V> void
validateConfiguredTypes(CacheConfig cacheConfig, K key, V value)
          Validates the configured key and value types matches the provided key, value types.
static
<K,V> void
validateConfiguredTypes(CacheConfig cacheConfig, K key, V value1, V value2)
          Validates the configured key and value types matches the provided key, value types.
static
<V> void
validateConfiguredValueType(Class<V> valueType, V value)
          Validates the value with value type.
static
<K> void
validateNotNull(K key)
          Validates that a key is not null.
static
<K,V> void
validateNotNull(K key, V value)
          Validates that key, value pair are both not null.
static
<K,V> void
validateNotNull(K key, V value1, V value2)
          Validates that key and multi values are not null.
static
<K,V> void
validateNotNull(Map<? extends K,? extends V> map)
          This validator ensures that no key or value is null in the provided map.
static
<K> void
validateNotNull(Set<? extends K> keys)
          Validates that none of the keys are null in set.
static void validateResults(Map<Integer,Object> results)
          Cache clear response validator, loop on results to validate that no exception exists on the result map.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

AWAIT_COMPLETION_TIMEOUT_SECONDS

public static final int AWAIT_COMPLETION_TIMEOUT_SECONDS
See Also:
Constant Field Values
Method Detail

validateResults

public static void validateResults(Map<Integer,Object> results)
Cache clear response validator, loop on results to validate that no exception exists on the result map. Throws the first exception in the map.

Parameters:
results - map of CacheClearResponse.

getPartitionId

protected static int getPartitionId(NodeEngine nodeEngine,
                                    Data key)

validateNotNull

public static <K> void validateNotNull(K key)
Validates that a key is not null.

Type Parameters:
K - the type of key.
Parameters:
key - the key to be validated.
Throws:
NullPointerException - if provided key is null.

validateNotNull

public static <K,V> void validateNotNull(K key,
                                         V value)
Validates that key, value pair are both not null.

Type Parameters:
K - the type of key.
V - the type of value.
Parameters:
key - the key to be validated.
value - the value to be validated.
Throws:
NullPointerException - if key or value is null.

validateNotNull

public static <K,V> void validateNotNull(K key,
                                         V value1,
                                         V value2)
Validates that key and multi values are not null.

Type Parameters:
K - the type of key.
V - the type of value.
Parameters:
key - the key to be validated.
value1 - first value to be validated.
value2 - second value to be validated.
Throws:
NullPointerException - if key or any value is null.

validateNotNull

public static <K> void validateNotNull(Set<? extends K> keys)
Validates that none of the keys are null in set.

Type Parameters:
K - the type of key.
Parameters:
keys - set of keys to be validated.
Throws:
NullPointerException - if provided key set contains a null key.

validateNotNull

public static <K,V> void validateNotNull(Map<? extends K,? extends V> map)
This validator ensures that no key or value is null in the provided map.

Type Parameters:
K - the type of key.
V - the type of value.
Parameters:
map - the map to be validated.
Throws:
NullPointerException - if provided map contains a null key or value in the map.

validateConfiguredTypes

public static <K> void validateConfiguredTypes(CacheConfig cacheConfig,
                                               K key)
                                    throws ClassCastException
Validates that the configured key matches the provided key.

Type Parameters:
K - the type of key.
Parameters:
cacheConfig - Cache configuration.
key - the key to be validated with its type.
Throws:
ClassCastException - if the provided key does not match with configured type.

validateConfiguredTypes

public static <K,V> void validateConfiguredTypes(CacheConfig cacheConfig,
                                                 K key,
                                                 V value)
                                    throws ClassCastException
Validates the configured key and value types matches the provided key, value types.

Type Parameters:
K - the type of key.
V - the type of value.
Parameters:
cacheConfig - Cache configuration.
key - the key to be validated.
value - the value to be validated.
Throws:
ClassCastException - if the provided key or value do not match with configured types.

validateConfiguredTypes

public static <K,V> void validateConfiguredTypes(CacheConfig cacheConfig,
                                                 K key,
                                                 V value1,
                                                 V value2)
                                    throws ClassCastException
Validates the configured key and value types matches the provided key, value types.

Type Parameters:
K - the type of key.
V - the type of value.
Parameters:
cacheConfig - Cache configuration.
key - the key to be validated.
value1 - value to be validated.
value2 - value to be validated.
Throws:
ClassCastException - if the provided key or value do not match with configured types.

validateConfiguredKeyType

public static <K> void validateConfiguredKeyType(Class<K> keyType,
                                                 K key)
                                      throws ClassCastException
Validates the key with key type.

Type Parameters:
K - the type of key.
Parameters:
keyType - key class.
key - key to be validated.
Throws:
ClassCastException - if the provided key do not match with keyType.

validateConfiguredValueType

public static <V> void validateConfiguredValueType(Class<V> valueType,
                                                   V value)
                                        throws ClassCastException
Validates the value with value type.

Type Parameters:
V - the type of value.
Parameters:
valueType - value class.
value - value to be validated.
Throws:
ClassCastException - if the provided value do not match with valueType.


Copyright © 2015 Hazelcast, Inc.. All Rights Reserved.