Package org.team1126.lib.util
Class Mutable<T>
java.lang.Object
org.team1126.lib.util.Mutable<T>
A simple mutable object that stores a value.
Useful for declaring primitives in an enclosing scope to be mutated inside a lambda, as lambdas prohibit capturing non final variables, with the exception of instance variables. This use case however should be executed with caution, as a race condition may occur if the lambda escapes its capturing thread.
Fortunately for our purposes, using this class in a command factory to provide stateful behavior does not suffer from aforementioned race conditions as commands are invoked synchronously.
-
Field Details
-
value
-
-
Constructor Details
-
Mutable
Create the mutable object.- Parameters:
value- The initial value to store.
-
-
Method Details