Class HxmValue
- All Implemented Interfaces:
AutoCloseable
General value container. Any value in a Hexaly Modeler can be contained in an instance of this class (integer, double, boolean, string, HxExpression, module, map, function and also non exposed types like files or dates).
Values come in two types: references and primitive values. Primitive values are integers, doubles, booleans and nil. All other values are references (including modules, functions, maps and strings).
The lifetime of primitive values is automatically managed by the modeler.
By contrast, references are managed by a memory counter. Any reference
returned by the modeler API must be freed by calling close(). To help you,
reference values can be grouped together in a HxmReferenceScope.
- Since:
- 10.0
-
Method Summary
Modifier and TypeMethodDescriptionbooleanasBool()Returns the value as a boolean.asClass()Returns the value as aHxmClass.doubleasDouble()Returns the value as a double.Returns the value as aHxExpression.Returns the value as aHxmFunction.longasInt()Returns the value as an integer.asMap()Returns the value as aHxmMap.asModule()Returns the value as aHxmModule.asString()Returns the value as a String.voidclose()Releases the reference.booleanReturns the HxmClass associated to this value if it is a reference.getType()Returns the type of the value.inthashCode()booleanisBool()Returns true if the value is a boolean value.booleanisClass()Returns true if the value is an HxmClass.booleanisDouble()Returns true if the value is a double value.booleanReturns true if the value is an HxExpression.booleanReturns true if the value is a HxmFunction.booleanisInt()Returns true if the value is an integer value.booleanisMap()Returns true if the value is an HxmMap.booleanisModule()Returns true if the value is an HxmModule.booleanisNil()Returns true if the value is nil.booleanisObject()Returns true if the value is an object.booleanisString()Returns true if the value is a string.
-
Method Details
-
close
public void close()Releases the reference. If this value was already released, returns immediately and does nothing. Invoking any method on this object after this operation will throw an exception.
Note: Releasing a reference does not necessarily imply that the underlying value object is destroyed. It is only destroyed if no more references point to it.
- Specified by:
closein interfaceAutoCloseable- Since:
- 11.0
-
getType
Returns the type of the value.- Returns:
- Type of the value.
- See Also:
-
getHxmClass
Returns the HxmClass associated to this value if it is a reference.- Since:
- 13.0
- See Also:
-
isObject
public boolean isObject()Returns true if the value is an object. Any value that is not nil, a boolean, an integer or a number is an object. In particular, strings, maps, functions or modules are objects.- Since:
- 13.0
-
isInt
public boolean isInt()Returns true if the value is an integer value. -
isDouble
public boolean isDouble()Returns true if the value is a double value. -
isBool
public boolean isBool()Returns true if the value is a boolean value. -
isMap
public boolean isMap()Returns true if the value is an HxmMap. -
isModule
public boolean isModule()Returns true if the value is an HxmModule. -
isClass
public boolean isClass()Returns true if the value is an HxmClass. -
isExpression
public boolean isExpression()Returns true if the value is an HxExpression. -
isFunction
public boolean isFunction()Returns true if the value is a HxmFunction. -
isString
public boolean isString()Returns true if the value is a string. -
isNil
public boolean isNil()Returns true if the value is nil. -
asInt
public long asInt()Returns the value as an integer. The value must be an integer. -
asDouble
public double asDouble()Returns the value as a double. The value must be a double. -
asBool
public boolean asBool()Returns the value as a boolean. The value must be a boolean. -
asString
Returns the value as a String. The value must be a string. -
asMap
Returns the value as aHxmMap. The value must be a map. -
asModule
Returns the value as aHxmModule. The value must be a module. -
asClass
Returns the value as aHxmClass. The value must be a class.- Since:
- 13.0
-
asFunction
Returns the value as aHxmFunction. The value must be a function. -
asExpression
Returns the value as aHxExpression. The value must be an expression. -
hashCode
public int hashCode() -
equals
-