Class ScopedValuesExamples
java.lang.Object
net.jrodolfo.java_evolution.java25.scoped_values.ScopedValuesExamples
Demonstrates scoped values, finalized in Java 25 by JEP 506.
This example keeps the code intentionally small so the lifecycle is visible: create a scoped-value key, bind a value to it for one operation, read the value while the operation runs, and observe that the binding is gone afterward.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanReports whether the user key has a value in the current execution scope.userInsideScope(String user) Binds a user name for the duration of one scoped operation.
-
Constructor Details
-
ScopedValuesExamples
public ScopedValuesExamples()
-
-
Method Details
-
userInsideScope
-
isUserBound
public boolean isUserBound()Reports whether the user key has a value in the current execution scope.- Returns:
truewhen the current code is running inside a user binding
-