Class ObjectHolder.KeyedHolder<C extends Serializable,V>

java.lang.Object
au.csiro.pathling.utilities.ObjectHolder.KeyedHolder<C,V>
Type Parameters:
C - the configuration type
V - the value type
All Implemented Interfaces:
ObjectHolder<C,V>, Closeable, AutoCloseable
Enclosing interface:
ObjectHolder<C extends Serializable,V>

public static class ObjectHolder.KeyedHolder<C extends Serializable,V> extends Object implements ObjectHolder<C,V>, Closeable
An implementation of ObjectHolder that memoises one instance per distinct configuration within the process. Unlike ObjectHolder.SingletonHolder this permits several configurations to coexist in the same JVM, which is required when a single process legitimately works with more than one configuration at a time (for example, querying two local terminology stores).
  • Method Details

    • getOrCreate

      @Nonnull public V getOrCreate(@Nonnull C config)
      Description copied from interface: ObjectHolder
      Retrieves the instance associated with given configuration and if necessary creates ones.
      Specified by:
      getOrCreate in interface ObjectHolder<C extends Serializable,V>
      Parameters:
      config - the configuration for the instance.
      Returns:
      the instance associated with the holder.
    • reset

      public void reset()
      Description copied from interface: ObjectHolder
      Destroys all the instances stored the underlying scope.
      Specified by:
      reset in interface ObjectHolder<C extends Serializable,V>
    • close

      public void close()
      Closes this holder and releases the system resources associated with every held instance. If the holder is already empty then invoking this method has no effect.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable