Class StringValue
This class extends Value<String> and adds convenience methods for string
equality testing, which are useful in lambdas and conditional logic.
Notes:
- This class is not thread-safe. For concurrent access, use synchronization or atomic classes.
Example:
See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringValuecreate()Creates a new empty string value.booleanChecks if the current value is equal to the specified value.booleanChecks if the current value matches any of the specified values.static StringValueCreates a new string value with the specified initial value.
-
Constructor Details
-
StringValue
public StringValue()Constructor. -
StringValue
Constructor.- Parameters:
value- The initial value.
-
-
Method Details
-
create
Creates a new empty string value.Example:
StringValue
name = StringValue.create ();assertNull (name .get());- Returns:
- A new string value.
-
of
Creates a new string value with the specified initial value.Example:
StringValue
name = StringValue.of ("Hello" );assertEquals ("Hello" ,name .get());- Parameters:
value- The initial value.- Returns:
- A new string value.
-
is
Checks if the current value is equal to the specified value.Uses
Utils.eq(Object, Object)for deep equality comparison, which handles nulls safely.Example:
StringValue
name = StringValue.of ("John" );assertTrue (name .is("John" ));assertFalse (name .is("Jane" ));// Handles null safely StringValueempty = StringValue.create ();assertTrue (empty .is(null )); -
isAny
Checks if the current value matches any of the specified values.Uses
Utils.eq(Object, Object)for deep equality comparison of each value.Example:
StringValue
name = StringValue.of ("John" );assertTrue (name .isAny("John" ,"Jane" ,"Bob" ));assertFalse (name .isAny("Alice" ,"Charlie" ));// Empty array returns false assertFalse (name .isAny());- Parameters:
values- The values to compare to.- Returns:
true if the current value matches any of the specified values.
-