Class SmartCache

java.lang.Object
org.uitnet.testing.smartfwk.ui.core.cache.SmartCache
Direct Known Subclasses:
DefaultSmartCache

public abstract class SmartCache
extends Object
Abstract SmartCache class that can be used to store the data and can be retrieved at any time. Also you can use events to inform subscriber for the change of cached data. NOTE: To use this cache, create a singleton class that extends this cache or you can use the default implementation DefaultSmartCache.
Author:
Madhav Krishna
  • Constructor Details

    • SmartCache

      public SmartCache()
  • Method Details

    • add

      public void add​(String key, Object value)
    • get

      public Object get​(String key)
      This returns the key value.If key does not present then return null.
      Parameters:
      key -
      Returns:
    • getCache

      public com.google.common.collect.ImmutableMap<String,​Object> getCache()
    • getNullAsKey

      public Object getNullAsKey​(String key)
      This returns the key value. If key does not present or key value is null then it will return key as value.
      Parameters:
      key -
      Returns:
    • removeAndGet

      public Object removeAndGet​(String key)
    • removeAndGetNullAsKey

      public Object removeAndGetNullAsKey​(String key)
    • getValueAsString

      public String getValueAsString​(String key)
    • getValueAsInteger

      public Integer getValueAsInteger​(String key)
    • getValueAsLong

      public Long getValueAsLong​(String key)
    • getValueAsDouble

      public Double getValueAsDouble​(String key)
    • getValueAsBoolean

      public Boolean getValueAsBoolean​(String key)
    • getMultiValueKeyValueAsString

      public String getMultiValueKeyValueAsString​(String key, String delimitter, String valueEnclosingChars)
      MultiValue params are like Array, List, Set
      Parameters:
      key -
      delimitter - - could be , or any string, if null then it will use default as ,
      valueEnclosingChars - like ' or " or empty/null (denotes no enclosing)
      Returns:
    • getAll

      public Map<String,​Object> getAll()
    • clear

      public void clear()
    • getKeysStartsWith

      public Set<String> getKeysStartsWith​(String startsWithStr)
    • getKeysEndsWith

      public Set<String> getKeysEndsWith​(String endsWithStr)
    • getEntriesForKeyesEndsWithText

      public Map<String,​Object> getEntriesForKeyesEndsWithText​(String text)
    • getEntriesForKeysStartsWithText

      public Map<String,​Object> getEntriesForKeysStartsWithText​(String text)
    • isKeyPresent

      public boolean isKeyPresent​(String key)
    • subscribe

      public void subscribe​(SmartCacheSubscriber subscriber)
    • publish

      public void publish​(SmartCache cache)