Class PropertyGetter
java.lang.Object
com.oracle.truffle.api.object.PropertyGetter
A lightweight property getter that allows getting the value of a
DynamicObject
property without any lookup or cache dispatch. Only objects of a specific
Shape are accepted. Therefore, it should only be
used where the object is already known to have the supported shape.- Since:
- 22.2
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionbooleanaccepts(DynamicObject receiver) Returnstrueif thisPropertyGettercan be used with the given receiver object to get the property's value.get(DynamicObject receiver) Gets the property's value from the given receiver object if the object has the supportedShape, i.e.doublegetDouble(DynamicObject receiver) Gets the property's value from the given receiver object if the object has the supportedShape.intgetFlags()Returns the flags associated with the property represented by this getter.intgetInt(DynamicObject receiver) Gets the property's value from the given receiver object if the object has the supportedShape.getKey()Returns the key of the property represented by this getter.longgetLong(DynamicObject receiver) Gets the property's value from the given receiver object if the object has the supportedShape.
-
Method Details
-
accepts
Returnstrueif thisPropertyGettercan be used with the given receiver object to get the property's value.- Parameters:
receiver- the receiver object- Returns:
trueif the shape of the receiver object is supported by thisPropertyGetter.- Since:
- 22.2
- See Also:
-
get
Gets the property's value from the given receiver object if the object has the supportedShape, i.e. the shape this property getter was created with. Otherwise, throws anIllegalArgumentException.- Parameters:
receiver- the receiver object- Returns:
- the property's value
- Throws:
IllegalArgumentException- if the object does not have the expected shape.- Since:
- 22.2
-
getInt
Gets the property's value from the given receiver object if the object has the supportedShape. Expects anintvalue or throws anUnexpectedResultExceptionif the value is of a different type. If the object's shape is not supported, throws anIllegalArgumentException.- Parameters:
receiver- the receiver object- Returns:
- the property's value
- Throws:
IllegalArgumentException- if the object does not have the expected shape.UnexpectedResultException- if the location does not contain an int value.- Since:
- 22.2
- See Also:
-
getLong
Gets the property's value from the given receiver object if the object has the supportedShape. Expects alongvalue or throws anUnexpectedResultExceptionif the value is of a different type. If the object's shape is not supported, throws anIllegalArgumentException.- Parameters:
receiver- the receiver object- Returns:
- the property's value
- Throws:
IllegalArgumentException- if the object does not have the expected shape.UnexpectedResultException- if the location does not contain a long value.- Since:
- 22.2
- See Also:
-
getDouble
Gets the property's value from the given receiver object if the object has the supportedShape. Expects adoublevalue or throws anUnexpectedResultExceptionif the value is of a different type. If the object's shape is not supported, throws anIllegalArgumentException.- Parameters:
receiver- the receiver object- Returns:
- the property's value
- Throws:
IllegalArgumentException- if the object does not have the expected shape.UnexpectedResultException- if the location does not contain a double value.- Since:
- 22.2
- See Also:
-
getKey
Returns the key of the property represented by this getter.- Since:
- 22.2
- See Also:
-
getFlags
public int getFlags()Returns the flags associated with the property represented by this getter.- Since:
- 22.2
- See Also:
-