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
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
containsExpression
(String expression) Validates the expression, checking it has at least one token.boolean
Returns the wrapped expression, ornull
if there is no expression.getValue()
Returns the wrapped value ornull
if there is no value.Returns the nevernull
wrapped value, or throws if no value is available.int
hashCode()
boolean
Returnstrue
if this wraps an expression, orfalse
if it is a value.static <T> ValueOrExpression
<T> newExpression
(String expression) Returns a wrapper for an expression.static ValueOrExpression
<String> newFileExpression
(String filePath) Returns a wrapper for an expression corresponding to a file path.static <T> ValueOrExpression
<T> newValue
(T value) Returns a wrapper for a value.static <T> ValueOrExpression
<T> newValueOrNull
(T value) Returns a wrapper for a value, ornull
if anull
value is provided.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
Returns a wrapper for an expression.- Type Parameters:
T
- type of value- Parameters:
expression
- The expression- Returns:
- a wrapper for an expression
- Throws:
NullPointerException
- if provided expression is null
-
newFileExpression
Returns a wrapper for an expression corresponding to a file path.- Parameters:
filePath
- The file path to use in the expression- Returns:
- a wrapper for an expression corresponding to a file path
-
newValue
Returns a wrapper for a value.- Type Parameters:
T
- type of value- Parameters:
value
- The actual value- Returns:
- a wrapper for a value
- Throws:
NullPointerException
- if provided value is null
-
newValueOrNull
Returns a wrapper for a value, ornull
if anull
value is provided.- Type Parameters:
T
- type of value- Parameters:
value
- The value which may benull
- Returns:
- a 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 wrapped expression, ornull
if there is no expression.- Returns:
- the wrapped expression, or
null
if there is no expression
-
getValue
Returns the wrapped value ornull
if there is no value.- Returns:
- the wrapped value or
null
if there is no value
-
getValueOrThrowIfExpression
Returns the nevernull
wrapped value, or throws if no value is available.- Returns:
- the never
null
wrapped value, or throws if no value is available - Throws:
ExpressionException
- if this expression does not contain a value
-
isExpression
public boolean isExpression()Returnstrue
if this wraps an expression, orfalse
if it is a value.- Returns:
true
if this wraps an expression, orfalse
if it is a value
-
equals
-
hashCode
public int hashCode() -
toString
-