java.lang.Object
com.wyu4.snowberryjam.compiler.data.values.ValueHolder
- Direct Known Subclasses:
InputHolder,InteractiveValueHolder,PublicFolderHolder,RandomHolder,TimeHolder,VariableReference
A pointer to a stored value.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCreates a pointer to null.ValueHolder(Object value) Creates a new pointer to a value -
Method Summary
Modifier and TypeMethodDescriptionstatic ValueHoldercheckValueIsConditional(ValueHolder condition) Check if aValueHolderobject is conditionalbooleanstatic ValueHolderfromNode(com.fasterxml.jackson.databind.JsonNode node) Manufacture a ValueHolder object from aJsonNodeobject.Object[]getArray()Get the stored value as anObjectarray.getId()Get the ID of the value holderGet the unparsed pointer.getSize()Get the value as a number.Get the stored value as aStringClass<?> getType()Get the type being pointed togetValue()Get the value being pointed to casted as anObject.private static booleanisPrimitive(com.fasterxml.jackson.databind.JsonNode node) Check if aJsonNodeis primitive, in the context of Snowberry JambooleanCheck if the type being pointed to is the same as parametertype.booleannotEmpty()Check if this holder doesn't point to nullbooleansuperEquals(Object obj) toString()
-
Field Details
-
value
The value to be pointing to. Could be anotherValueHolderobject, or null- See Also:
-
-
Constructor Details
-
ValueHolder
public ValueHolder()Creates a pointer to null. Flags as empty.- See Also:
-
ValueHolder
Creates a new pointer to a value- Parameters:
value- The value to point towards. Type should be compatible with the compiler.
-
-
Method Details
-
isPrimitive
private static boolean isPrimitive(com.fasterxml.jackson.databind.JsonNode node) Check if aJsonNodeis primitive, in the context of Snowberry Jam -
fromNode
Manufacture a ValueHolder object from aJsonNodeobject. Uses the ID node to identify which type ofValueHoldershould be created- Parameters:
node- Node containing Snowberry Jam Source code- Returns:
- A ValueHolder object. Might be casted from child classes.
- See Also:
-
checkValueIsConditional
public static ValueHolder checkValueIsConditional(ValueHolder condition) throws IllegalArgumentException Check if aValueHolderobject is conditional- Parameters:
condition-ValueHolderobject to check- Returns:
- The
conditionparameter, untouched. - Throws:
IllegalArgumentException- if the value holder is not conditional.
-
getValue
Get the value being pointed to casted as anObject. The contents being returned by this method are mutable.- Returns:
- The value being pointed to, in its current state.
-
getPointer
Get the unparsed pointer. Could be a primitive or non-primitive value.- Returns:
- The value or the pointer to a value.
-
getArray
Get the stored value as anObjectarray. If the original value was already anObjectarray, it wil lremain untouched. Otherwise, it will take the string format of the value and return an array of all the characters (casted toString)- Returns:
Objectarray- See Also:
-
getString
Get the stored value as aString- Returns:
- The value casted to a
String. If the value is an array, this method will take care of converting it into a string. - See Also:
-
getType
Get the type being pointed to- Returns:
- The class type
- See Also:
-
isType
Check if the type being pointed to is the same as parametertype.- Parameters:
type- The other type- Returns:
trueif tne value shares the same class.falseif not.
-
notEmpty
public boolean notEmpty()Check if this holder doesn't point to null- Returns:
trueif this points to a value,falseif it points tonull
-
getSize
Get the value as a number. If the value is numerical, it returns the value as aDouble. If it's aStringor anArray, it will return its length. If it's aBoolean,truewill return 1, andfalsewill return 0.- Returns:
Doublerepresentation of the value
-
getId
Get the ID of the value holder- Returns:
- Corresponding
SourceId
-
equals
-
superEquals
-
toString
-