Schnittstelle Store<T>


@API(status=EXPERIMENTAL, since="1.2.3") public interface Store<T>
Experimental feature. Not ready for public usage yet.
  • Verschachtelte Klassen - Übersicht

    Verschachtelte Klassen
    Modifizierer und Typ
    Schnittstelle
    Beschreibung
    static interface 
    Any value that implements this interface will automatically be closed when its store goes out of scope.
    static class 
     
  • Methodenübersicht

    Modifizierer und Typ
    Methode
    Beschreibung
    static <T extends @Nullable Object>
    Store<T>
    create(Object identifier, Lifespan lifespan, Supplier<T> initialValueSupplier)
    Create a new store for storing and retrieving values and objects in lifecycle hooks and lifecycle-dependent methods.
    static <T extends @Nullable Object>
    Store<T>
    free(Supplier<T> initializer)
    Create a "free" store, i.e. one that lives independently from a test run, property or try.
    get()
     
    static <T extends @Nullable Object>
    Store<T>
    get(Object identifier)
    Retrieve a store that must be created somewhere else.
    static <T extends @Nullable Object>
    Store<T>
    getOrCreate(Object identifier, Lifespan lifespan, Supplier<T> initialValueSupplier)
    Find an existing store or create a new one if it doesn't exist.
     
    void
     
    void
    update(Function<T,T> updater)
     
  • Methodendetails

    • get

      T get()
    • lifespan

      Lifespan lifespan()
    • update

      void update(Function<T,T> updater)
    • reset

      @API(status=INTERNAL, since="1.6.3") void reset()
    • create

      static <T extends @Nullable Object> Store<T> create(Object identifier, Lifespan lifespan, Supplier<T> initialValueSupplier)
      Create a new store for storing and retrieving values and objects in lifecycle hooks and lifecycle-dependent methods.

      Stores are created with respect to the current test / property. Therefore you _must not save created stores in member variables_, unless the containing object is unique per test / property.

      Typparameter:
      T - The type of object to store
      Parameter:
      identifier - Any object to identify a store. Must be globally unique and stable, i.e. hashCode and equals must not change.
      lifespan - A stored object's lifespan
      initialValueSupplier - Supplies the value to be used for initializing the store depending on its lifespan
      Gibt zurück:
      New store instance
    • getOrCreate

      static <T extends @Nullable Object> Store<T> getOrCreate(Object identifier, Lifespan lifespan, Supplier<T> initialValueSupplier)
      Find an existing store or create a new one if it doesn't exist.

      Stores are created with respect to the current test / property. Therefore you _must not save created stores in member variables_, unless the containing object is unique per test / property.

      Typparameter:
      T - The type of object to store
      Parameter:
      identifier - Any object to identify a store. Must be globally unique and stable, i.e. hashCode and equals must not change.
      lifespan - A stored object's lifespan
      initialValueSupplier - Supplies the value to be used for initializing the store depending on its lifespan
      Gibt zurück:
      New or existing store instance
    • get

      static <T extends @Nullable Object> Store<T> get(Object identifier)
      Retrieve a store that must be created somewhere else.
      Typparameter:
      T - The type of object to store
      Parameter:
      identifier - Any object to identify a store. Must be globally unique and stable, i.e. hashCode and equals must not change.
      Gibt zurück:
      Existing store instance
      Löst aus:
      CannotFindStoreException
    • free

      @API(status=EXPERIMENTAL, since="1.5.0") static <T extends @Nullable Object> Store<T> free(Supplier<T> initializer)
      Create a "free" store, i.e. one that lives independently from a test run, property or try.
      Typparameter:
      T - The type of object to store
      Parameter:
      initializer - Supplies the value to be used for initializing the store depending on its lifespan
      Gibt zurück:
      New store instance