Class ScopedValuesExamples
java.lang.Object
net.jrodolfo.java_evolution.java25.ScopedValuesExamples
Demonstrates scoped values, finalized in Java 25 by JEP 506.
Scoped values solve a common context-passing problem. Data such as a user, request ID, or tenant often needs to be available through a call chain without adding parameters everywhere. Compared with mutable thread-local state, scoped values bind immutable data to a bounded dynamic scope, making cleanup and ownership easier to reason about.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionuserInsideScope(String user) Binds a scoped value for the duration of one call.booleanChecks whether the scoped value is bound outside a scope.
-
Constructor Details
-
ScopedValuesExamples
public ScopedValuesExamples()
-
-
Method Details
-
userInsideScope
-
userIsBoundOutsideScope
public boolean userIsBoundOutsideScope()Checks whether the scoped value is bound outside a scope.- Returns:
- whether the scoped value is currently bound
-