be.ehealth.technicalconnector.cache.impl

## Class HashMapCache<K,V>

- java.lang.Object
- - be.ehealth.technicalconnector.cache.impl.HashMapCache<K,V>

- All Implemented Interfaces:
    Cache<K,V>, ConfigurableImplementation

      public class HashMapCache<K,V>
      extends Object
      implements Cache<K,V>, ConfigurableImplementation

  Implementation of `Cache` based on a HashMap implementation. Warning Not safe to use in a multi threaded environment.

- - ### Field Summary

    - ### Fields inherited from interface be.ehealth.technicalconnector.cache.Cache

      `CACHE_EXPIRY_DURATION, CACHE_EXPIRY_TYPE, CACHE_NAME`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `HashMapCache()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `clear()` Clear the cache.
    `boolean` | `containsKey(K key)` Returns true, if there is a mapping for the specified key.
    `V` | `get(K key)` Returns a value associated by the given key, that contains a non expired value.
    `String` | `getName()` A configured or generated name of this cache instance.
    `void` | `initialize(Map<String,Object> parameterMap)` initializes the implementation with additional parameters.
    `void` | `put(K key, V value)` Updates an existing cache entry for the specified key, so it associates the given value, or, insert a new cache entry for this key and value.
    `void` | `putAll(Map<K,V> map)`
    `void` | `remove(K key)` Removes the mapping for a key from the cache if it is present.

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### HashMapCache

          public HashMapCache()

  - ### Method Detail

    - #### getName

          public String getName()

      Description copied from interface: `Cache`
      A configured or generated name of this cache instance.
      Specified by:
        `getName` in interface `Cache<K,V>`
      Returns:
        name of this cache or null for anonymous caches.

    - #### get

          public V get(K key)

      Description copied from interface: `Cache`
      Returns a value associated by the given key, that contains a non expired value. If no value is present or it is expired the cache loader is invoked, if configured, or `null` is returned.
      Specified by:
        `get` in interface `Cache<K,V>`
      Parameters:
        `key` - key with which the specified value is associated
      Returns:
        the value associated with the specified key, or `null` if there was no mapping for the key.

    - #### containsKey

          public boolean containsKey(K key)

      Description copied from interface: `Cache`
      Returns true, if there is a mapping for the specified key.
      Specified by:
        `containsKey` in interface `Cache<K,V>`
      Parameters:
        `key` - key which association should be checked
      Returns:
        `true`, if this cache contains a mapping for the specified key

    - #### put

          public void put(K key,
                          V value)

      Description copied from interface: `Cache`
      Updates an existing cache entry for the specified key, so it associates the given value, or, insert a new cache entry for this key and value.
      Specified by:
        `put` in interface `Cache<K,V>`
      Parameters:
        `key` - key with which the specified value is associated
        `value` - value to be associated with the specified key

    - #### remove

          public void remove(K key)

      Description copied from interface: `Cache`
      Removes the mapping for a key from the cache if it is present.
      Specified by:
        `remove` in interface `Cache<K,V>`
      Parameters:
        `key` - key which mapping is to be removed from the cache, not null

    - #### clear

          public void clear()

      Description copied from interface: `Cache`
      Clear the cache.
      Specified by:
        `clear` in interface `Cache<K,V>`

    - #### putAll

          public void putAll(Map<K,V> map)

      Specified by:
        `putAll` in interface `Cache<K,V>`

    - #### initialize

          public void initialize(Map<String,Object> parameterMap)
                          throws TechnicalConnectorException

      Description copied from interface: `ConfigurableImplementation`
      initializes the implementation with additional parameters.
      Specified by:
        `initialize` in interface `ConfigurableImplementation`
      Parameters:
        `parameterMap` - Map with for each propertyString ,the input parameter as Object.
      Throws:
        `TechnicalConnectorException` - if the parameterMap is not correct.

Connector Packaging TECHNICAL 4.8.4 API
Copyright © {inceptionYear}-2025 eHealth. All Rights Reserved.