public final class PropertyGetter extends Object
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.Shape.makePropertyGetter(Object),
DynamicObjectLibrary| Modifier and Type | Method and Description |
|---|---|
boolean |
accepts(DynamicObject receiver)
Returns
true if this PropertyGetter can be used with the given receiver
object to get the property's value. |
Object |
get(DynamicObject receiver)
Gets the property's value from the given receiver object if the object has the supported
Shape, i.e. |
double |
getDouble(DynamicObject receiver)
Gets the property's value from the given receiver object if the object has the supported
Shape. |
int |
getFlags()
Returns the flags associated with the property represented by this getter.
|
int |
getInt(DynamicObject receiver)
Gets the property's value from the given receiver object if the object has the supported
Shape. |
Object |
getKey()
Returns the key of the property represented by this getter.
|
long |
getLong(DynamicObject receiver)
Gets the property's value from the given receiver object if the object has the supported
Shape. |
public boolean accepts(DynamicObject receiver)
true if this PropertyGetter can be used with the given receiver
object to get the property's value.receiver - the receiver objecttrue if the shape of the receiver object is supported by this
PropertyGetter.PropertyGetter.get(DynamicObject)public Object get(DynamicObject receiver)
Shape, i.e. the shape this property getter was created with. Otherwise, throws an
IllegalArgumentException.receiver - the receiver objectIllegalArgumentException - if the object does not have the expected shape.public int getInt(DynamicObject receiver) throws UnexpectedResultException
Shape. Expects an int value or throws an UnexpectedResultException if
the value is of a different type. If the object's shape is not supported, throws an
IllegalArgumentException.receiver - the receiver objectIllegalArgumentException - if the object does not have the expected shape.UnexpectedResultException - if the location does not contain an int value.PropertyGetter.get(DynamicObject)public long getLong(DynamicObject receiver) throws UnexpectedResultException
Shape. Expects a long value or throws an UnexpectedResultException if
the value is of a different type. If the object's shape is not supported, throws an
IllegalArgumentException.receiver - the receiver objectIllegalArgumentException - if the object does not have the expected shape.UnexpectedResultException - if the location does not contain a long value.PropertyGetter.get(DynamicObject)public double getDouble(DynamicObject receiver) throws UnexpectedResultException
Shape. Expects a double value or throws an UnexpectedResultException
if the value is of a different type. If the object's shape is not supported, throws an
IllegalArgumentException.receiver - the receiver objectIllegalArgumentException - if the object does not have the expected shape.UnexpectedResultException - if the location does not contain a double value.PropertyGetter.get(DynamicObject)public Object getKey()
Property.getKey()public int getFlags()
Property.getFlags()