Package com.guinetik.corefun
Class DefaultComputable<T>
java.lang.Object
com.guinetik.corefun.DefaultComputable<T>
- Type Parameters:
T- the type of the value
- All Implemented Interfaces:
Computable<T>
Default immutable implementation of
Computable.
DefaultComputable provides a simple, thread-safe implementation of the
Computable interface. The wrapped value is stored as a final field,
ensuring immutability.
Thread Safety
This class is immutable and therefore thread-safe. The wrapped value itself should also be immutable or thread-safe for the container to be fully thread-safe.
Usage
Typically, you should use Computable.of(Object) rather than constructing
this class directly:
Computable<String> comp = Computable.of("value"); // Preferred
Computable<String> comp2 = new DefaultComputable<>("value"); // Also valid
- Since:
- 0.1.0
- Author:
- Guinetik <guinetik@gmail.com>
- See Also:
-
Constructor Details
-
DefaultComputable
Creates a new DefaultComputable with the given value.- Parameters:
value- the value to wrap
-
-
Method Details
-
getValue
Description copied from interface:ComputableRetrieves the value managed by this computable.- Specified by:
getValuein interfaceComputable<T>- Returns:
- the current value
-
toString
-
equals
-
hashCode
public int hashCode()
-