Interface AsyncContextMap


  • public interface AsyncContextMap
    The key-value map stored in the AsyncContext.
    • Method Detail

      • get

        @Nullable
        <T> T get​(AsyncContextMap.Key<T> key)
        Get the value associated with key, or null if no value is associated.
        Type Parameters:
        T - The anticipated type of object associated with key.
        Parameters:
        key - the key to lookup.
        Returns:
        the value associated with key, or null if no value is associated.
      • containsKey

        boolean containsKey​(AsyncContextMap.Key<?> key)
        Determine if this context contains a key/value entry corresponding to key.
        Parameters:
        key - the key to lookup.
        Returns:
        true if this context contains a key/value entry corresponding to key. false otherwise.
      • isEmpty

        boolean isEmpty()
        Determine if there are no key/value pairs in this AsyncContextMap.
        Returns:
        true if there are no key/value pairs in this AsyncContextMap.
      • put

        @Nullable
        <T> T put​(AsyncContextMap.Key<T> key,
                  T value)
        Put a new key/value pair into this AsyncContextMap.
        Type Parameters:
        T - The type of object associated with key.
        Parameters:
        key - the key used to index value. Cannot be null.
        value - the value to put.
        Returns:
        The previous value associated with the key, or null if there was none. A null value may also indicate there was a previous value which was null.
        Throws:
        java.lang.NullPointerException - if key is null, or value is null.
        java.lang.UnsupportedOperationException - if this method is not supported.
      • putAll

        void putAll​(java.util.Map<AsyncContextMap.Key<?>,​java.lang.Object> map)
        Put all the key/value pairs into this AsyncContextMap.
        Parameters:
        map - The entries to insert into this AsyncContextMap.
        Throws:
        java.util.ConcurrentModificationException - Done on a best effort basis if entries is detected to be modified while attempting to put all entries.
        java.lang.UnsupportedOperationException - if this method is not supported.
      • remove

        @Nullable
        <T> T remove​(AsyncContextMap.Key<T> key)
        Remove a key/value pair from this AsyncContextMap, and get the previous value (if one exists).
        Type Parameters:
        T - The type of object associated with key.
        Parameters:
        key - The key which identifies the key/value to remove.
        Returns:
        the previous value associated with key, or null if there was none. A null value may also indicate there was a previous value which was null. If the AsyncContextMap implementation is immutable this may be a new object.
        Throws:
        java.lang.UnsupportedOperationException - if this method is not supported.
      • removeAll

        boolean removeAll​(java.lang.Iterable<AsyncContextMap.Key<?>> entries)
        Remove all key/value pairs from this AsyncContextMap associated with the keys from the Iterable.
        Parameters:
        entries - The entries to remove from this AsyncContextMap.
        Returns:
        true if this map has changed as a result of this operation.
        Throws:
        java.util.ConcurrentModificationException - Done on a best effort basis if entries is detected to be modified while attempting to remove all entries.
        java.lang.UnsupportedOperationException - if this method is not supported.
      • clear

        void clear()
        Clear the contents of this AsyncContextMap.
        Throws:
        java.lang.UnsupportedOperationException - if this method is not supported.
      • forEach

        @Nullable
        AsyncContextMap.Key<?> forEach​(java.util.function.BiPredicate<AsyncContextMap.Key<?>,​java.lang.Object> consumer)
        Iterate over the key/value pairs contained in this request context.
        Parameters:
        consumer - Each key/value pair will be passed as arguments to this BiPredicate. Returns true if the consumer wants to keep iterating or false to stop iteration at the current key/value pair.
        Returns:
        null if consumer iterated through all key/value pairs or the AsyncContextMap.Key at which the iteration stopped.
      • copy

        AsyncContextMap copy()
        Create an isolated copy of the current map. The return value contents are the same as this AsyncContextMap but modifications to this AsyncContextMap are not visible in the return value, and visa-versa.
        Returns:
        an isolated copy of the current map. Tcontents are the same as this AsyncContextMap but modifications to this AsyncContextMap are not visible in the return value, and visa-versa.