Gets the current value of the local. @return the local value
()
| 159 | * @return the local value |
| 160 | */ |
| 161 | @SuppressWarnings("unchecked") |
| 162 | public final Optional<T> get() { |
| 163 | final Optional<?>[] ctx = threadLocal.get(); |
| 164 | if (ctx == null || ctx.length <= position) |
| 165 | return Optional.empty(); |
| 166 | |
| 167 | final Optional<?> v = ctx[position]; |
| 168 | if (v == null) |
| 169 | return Optional.empty(); |
| 170 | else |
| 171 | return (Optional<T>) v; |
| 172 | } |
| 173 | |
| 174 | /** |
| 175 | * Executes the supplier with the provided value and then rolls back to the |