Interface ContextLocal<T>

    • Method Detail

      • registerLocal

        static <T> ContextLocal<T> registerLocal​(Class<T> type)
        Registers a context local storage.
        Returns:
        the context local storage
      • registerLocal

        static <T> ContextLocal<T> registerLocal​(Class<T> type,
                                                 Function<T,​T> duplicator)
        Registers a context local storage.
        Returns:
        the context local storage
      • get

        default T get​(Context context)
        Get the local data from the context.
        Returns:
        the local data
      • get

        default T get​(Context context,
                      Supplier<? extends T> initialValueSupplier)
        Get the local data from the context, when it does not exist then call initialValueSupplier to obtain the initial value. The supplier can be called multiple times when several threads call this method concurrently.
        Parameters:
        initialValueSupplier - the supplier of the initial value
        Returns:
        the local data
      • put

        default void put​(Context context,
                         T data)
        Put local data in the context.
        Parameters:
        data - the data
      • remove

        default void remove​(Context context)
        Remove the local data from the context.
      • put

        default void put​(Context context,
                         AccessMode accessMode,
                         T value)
        Like #put(Context, T) but with an accessMode.