Java SE API

ScopedValue.where()

Java 25 final API; establish a binding for the subsequent run or call. Example not executed.

Formal Syntax & Structure

java syntaxjava
static <T> ScopedValue.Carrier where(ScopedValue<T> key, T value)

Working Example

Example Snippetjava
public class Main {    private static final ScopedValue<String> REQUEST = ScopedValue.newInstance();    static void report() { System.out.println(REQUEST.get()); }    public static void main(String[] args) {        ScopedValue.where(REQUEST, "R-17").run(Main::report);        System.out.println(REQUEST.isBound());    }}
Java Reference