Interface TypeAssertion<K,V>

Type Parameters:
K - the type of the cache entry keys
V - 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 a NamedMap.Option for asserting the type of keys and values used with a NamedCache.
Since:
Coherence 12.2.1
Author:
bko 2015.06.15
  • Field Details

    • 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 Details

    • assertTypeSafety

      boolean assertTypeSafety(String sCacheName, CacheMapping cacheMapping, boolean fLog) throws IllegalArgumentException
      Asserts the type compatibility of a named cache given the CacheMapping that defines the cache.
      Parameters:
      sCacheName - the name of the cache
      cacheMapping - the CacheMapping
      fLog - when true, log warning if typing mismatch between CacheMapping configuration and this TypeAssertion; 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 the TypeAssertion 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 the CacheMapping that defines the cache.
      Parameters:
      sCacheName - the name of the cache
      cacheMapping - the CacheMapping
      Returns:
      false if warning logged about the assertion, true otherwise.
      Throws:
      IllegalArgumentException - when types used with the TypeAssertion are illegal according to the configuration
    • withTypes

      static <K, V> TypeAssertion<K,V> withTypes(Class<K> clsKey, Class<V> clsValue)
      Obtains a TypeAssertion that asserts the specified types are configured for a cache.
      Type Parameters:
      K - the key type
      V - the value type
      Parameters:
      clsKey - the desired key type
      clsValue - the desired value type
      Returns:
      a TypeAssertion
    • withRawTypes

      @Default static TypeAssertion withRawTypes()
      Obtains a TypeAssertion 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 a TypeAssertion that allows NamedCaches to be acquired without type-checking, warnings or log messages.
      Type Parameters:
      K - the key type
      V - the value type
      Returns:
      a TypeAssertion