Class GenerationStateStore<T>

java.lang.Object
io.jmix.core.impl.metadata.GenerationStateStore<T>
Type Parameters:
T - type of generation-local state

public class GenerationStateStore<T> extends Object
Stores lazily created state objects keyed by metadata generation identifier.

Intended for singleton services that need separate caches or derived structures for each published metadata generation.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final ConcurrentHashMap<Long,T>
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Removes cached state of all metadata generations.
    @Nullable T
    get(long generationId)
    Returns cached state for the specified metadata generation.
    getOrCreate(long generationId, Supplier<T> factory)
    Returns state associated with the specified metadata generation, creating it lazily when absent.
    void
    remove(long generationId)
    Removes cached state of the specified metadata generation.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • GenerationStateStore

      public GenerationStateStore()
  • Method Details

    • getOrCreate

      public T getOrCreate(long generationId, Supplier<T> factory)
      Returns state associated with the specified metadata generation, creating it lazily when absent.
      Parameters:
      generationId - metadata generation identifier
      factory - state factory used for the first access to the generation
      Returns:
      generation-local state
    • get

      public @Nullable T get(long generationId)
      Returns cached state for the specified metadata generation.
      Parameters:
      generationId - metadata generation identifier
      Returns:
      generation-local state or null if it has not been created
    • remove

      public void remove(long generationId)
      Removes cached state of the specified metadata generation.
      Parameters:
      generationId - metadata generation identifier
    • clear

      public void clear()
      Removes cached state of all metadata generations.