Package com.tangosol.config.expression
Class Value
- java.lang.Object
-
- com.tangosol.config.expression.Value
-
public final class Value extends Object
AValueis an immutable object that represents a value whose type is unknown at compile time. That is, the type of the value will only be known at runtime when it's requested.Much like a Variant (wikipedia) a
Valuepermits runtime coercion into other types, as and when required.- Since:
- Coherence 12.1.2
- Author:
- bo 2011.06.05
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> Tas(Class<T> clzType)Attempts to return the value of theValuecoerced to a specified type.Objectget()booleanisNull()Determines if theValuerepresents anullvalue.booleansupports(Class<?> clzType)Determines if theValuesupports conversion/coercion to the specified type.StringtoString()
-
-
-
Method Detail
-
isNull
public boolean isNull()
Determines if theValuerepresents anullvalue.- Returns:
trueif the value of theValueisnull, otherwisefalse
-
supports
public boolean supports(Class<?> clzType)
Determines if theValuesupports conversion/coercion to the specified type.NOTE: This does not test whether the
Valuecan be coerced without an exception.- Parameters:
clzType- the type to which theValueshould be coerced- Returns:
trueif type is coercable,falseotherwise
-
as
public <T> T as(Class<T> clzType) throws ClassCastException, UnknownFormatConversionException, NumberFormatException
Attempts to return the value of theValuecoerced to a specified type.- Type Parameters:
T- the expected type of the value- Parameters:
clzType- the expected type of the value (the value to coerce to)- Returns:
- the
Valuecoerced in the required type - Throws:
ClassCastException- If the value of theValuecan't be coerced to the specified typeNumberFormatException- If the value of theValuecan't be coerced to the specified typeUnknownFormatConversionException- If the value of theValuecan't be coerced to the specified type
-
-