Package org.forgerock.opendj.config
Class ValueOrExpression<T>
java.lang.Object
org.forgerock.opendj.config.ValueOrExpression<T>
- Type Parameters:
T
- type of value that can be held
Wraps either a value of a given type or an expression string containing at least one token.
Token(s) in an expression must use the pattern:
&{some.token}Example: a
ValueOrExpression<Integer>
could contain either the integer value 4444 or
the expression "&{port}".-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
containsExpression
(String expression) Validates the expression, checking it has at least one token.boolean
Returns the expression if any.getValue()
Returns the value if any.Returns the value or throws if no value is available.int
hashCode()
boolean
Indicates if this wraps an expression.static <T> ValueOrExpression<T>
newExpression
(String expression) Creates an expression.static ValueOrExpression<String>
newFileExpression
(String filePath) Creates an expression corresponding to a file path.static <T> ValueOrExpression<T>
newValue
(T value) Creates a value.static <T> ValueOrExpression<T>
newValueOrNull
(T value) Creates a new ValueOrExpression that wraps the provided value if the value is notnull
.toString()
-
Field Details
-
TOKEN_START
The marker of start for a commons-config token.- See Also:
-
TOKEN_END
The marker of end for a commons-config token.- See Also:
-
-
Method Details
-
newExpression
Creates an expression.- Type Parameters:
T
- type of value- Parameters:
expression
- The expression- Returns:
- the wrapper for an expression
- Throws:
NullPointerException
- if provided expression is null
-
newFileExpression
Creates an expression corresponding to a file path.- Parameters:
filePath
- The file path to use in the expression- Returns:
- the wrapper for an expression
-
newValue
Creates a value.- Type Parameters:
T
- type of value- Parameters:
value
- The actual value- Returns:
- the wrapper for a value
- Throws:
NullPointerException
- if provided value is null
-
newValueOrNull
Creates a new ValueOrExpression that wraps the provided value if the value is notnull
.- Type Parameters:
T
- type of value- Parameters:
value
- The value which may benull
- Returns:
- the wrapper for a value, or
null
if anull
value is provided
-
containsExpression
Validates the expression, checking it has at least one token.- Parameters:
expression
- The expression to validate- Returns:
true
if the expression is valid,false
otherwise
-
getExpression
Returns the expression if any.- Returns:
- the wrapped expression or
null
if there is no expression
-
getValue
Returns the value if any.- Returns:
- the wrapped value or
null
if there is no value
-
getValueOrThrowIfExpression
Returns the value or throws if no value is available.- Returns:
- the wrapped value, which is never
null
- Throws:
ExpressionException
- if this expression does not contain a value
-
isExpression
public boolean isExpression()Indicates if this wraps an expression.- Returns:
true
if this is an expression, orfalse
if it is a value
-
equals
-
hashCode
public int hashCode() -
toString
-