Package com.tangosol.net.cache
Interface TypeAssertion<K,V>
-
- Type Parameters:
K
- the type of the cache entry keysV
- the type of the cache entry values
- All Superinterfaces:
NamedMap.Option
- All Known Implementing Classes:
TypeAssertion.WithTypesAssertion
public interface TypeAssertion<K,V> extends NamedMap.Option
Defines aNamedMap.Option
for asserting the type of keys and values used with aNamedCache
.- Since:
- Coherence 12.2.1
- Author:
- bko 2015.06.15
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
TypeAssertion.WithTypesAssertion<K,V>
-
Field Summary
Fields Modifier and Type Field Description static TypeAssertion
WITH_RAW_TYPES
When used warnings will be issued where types are configured but not used.static TypeAssertion
WITHOUT_TYPE_CHECKING
When used no type checking will occur and no warnings will be generated.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default boolean
assertTypeSafety(String sCacheName, CacheMapping cacheMapping)
Asserts the type compatibility of a named cache given theCacheMapping
that defines the cache.boolean
assertTypeSafety(String sCacheName, CacheMapping cacheMapping, boolean fLog)
Asserts the type compatibility of a named cache given theCacheMapping
that defines the cache.static <K,V>
TypeAssertion<K,V>withoutTypeChecking()
Obtains aTypeAssertion
that allows NamedCaches to be acquired without type-checking, warnings or log messages.static TypeAssertion
withRawTypes()
Obtains aTypeAssertion
that allows NamedCaches to be acquired and assigned to a raw NamedCache reference.static <K,V>
TypeAssertion<K,V>withTypes(Class<K> clsKey, Class<V> clsValue)
Obtains aTypeAssertion
that asserts the specified types are configured for a cache.
-
-
-
Field Detail
-
WITHOUT_TYPE_CHECKING
static final TypeAssertion WITHOUT_TYPE_CHECKING
When used no type checking will occur and no warnings will be generated.
-
WITH_RAW_TYPES
static final TypeAssertion WITH_RAW_TYPES
When used warnings will be issued where types are configured but not used.
-
-
Method Detail
-
assertTypeSafety
boolean assertTypeSafety(String sCacheName, CacheMapping cacheMapping, boolean fLog) throws IllegalArgumentException
Asserts the type compatibility of a named cache given theCacheMapping
that defines the cache.- Parameters:
sCacheName
- the name of the cachecacheMapping
- theCacheMapping
fLog
- when true, log warning if typing mismatch betweenCacheMapping
configuration and thisTypeAssertion
; specifically, one uses raw types and the other asserts specific types.- Returns:
- false if warning logged about the assertion, true otherwise.
- Throws:
IllegalArgumentException
- when types used with theTypeAssertion
are illegal according to the configuration
-
assertTypeSafety
default boolean assertTypeSafety(String sCacheName, CacheMapping cacheMapping) throws IllegalArgumentException
Asserts the type compatibility of a named cache given theCacheMapping
that defines the cache.- Parameters:
sCacheName
- the name of the cachecacheMapping
- theCacheMapping
- Returns:
- false if warning logged about the assertion, true otherwise.
- Throws:
IllegalArgumentException
- when types used with theTypeAssertion
are illegal according to the configuration
-
withTypes
static <K,V> TypeAssertion<K,V> withTypes(Class<K> clsKey, Class<V> clsValue)
Obtains aTypeAssertion
that asserts the specified types are configured for a cache.- Type Parameters:
K
- the key typeV
- the value type- Parameters:
clsKey
- the desired key typeclsValue
- the desired value type- Returns:
- a
TypeAssertion
-
withRawTypes
@Default static TypeAssertion withRawTypes()
Obtains aTypeAssertion
that allows NamedCaches to be acquired and assigned to a raw NamedCache reference. A debug log message will be raised for caches that have been configured with specific types.- Returns:
- a
TypeAssertion
-
withoutTypeChecking
static <K,V> TypeAssertion<K,V> withoutTypeChecking()
Obtains aTypeAssertion
that allows NamedCaches to be acquired without type-checking, warnings or log messages.- Type Parameters:
K
- the key typeV
- the value type- Returns:
- a
TypeAssertion
-
-