Class Cached<T>

java.lang.Object
overit.geocall.cache.Cached<T>
Type Parameters:
T - type of the cached element
All Implemented Interfaces:
Serializable

public class Cached<T> extends Object implements Serializable
Wrapper class that holds references to an element in the Cache.
See Also:
  • Constructor Details

    • Cached

      public Cached(@NonNull Entry<?,T> entry)
      Create a new cached element reference from its cache's entry
      Parameters:
      entry - instance that identify the item within the Cache
    • Cached

      public Cached(@NotNull @NotNull Entry<?,T> entry, @NotNull @NotNull Item<?,T> item)
      Create a new Cached using the provided parameters.
      Parameters:
      entry - Entry about the item present inside the Cache.
      item - Item about the value associated with the entry present in Cache.
  • Method Details

    • get

      public T get()
      Get the cached element. If the element has not been extracted yet or if it has been invalidated, the element will be re-loaded from scratch from the cache
      Returns:
      the cached element
    • getEntry

      public Entry<?,T> getEntry()
      Get the entry that identifies this cached element within the Cache.
      Returns:
      the Entry instance used to identify the cached item
    • invalidate

      public void invalidate()
      Invalidate the cache's item. This force the re-load the next time the get() method will be called
    • clear

      public void clear()
      Clear this cache in order to force reloading on the next get
    • isValid

      public boolean isValid()
      Check if the cached object is still valid or must be reloaded from the cache
      Returns:
      true if the cached element is still valid, false otherwise