Class ObjectVariableResolver<T>
java.lang.Object
com.blackrook.rookscript.resolvers.variable.ObjectVariableResolver<T>
- Type Parameters:
T
- the object type.
- All Implemented Interfaces:
ScriptVariableResolver
A variable resolver that wraps an object instance's fields and getters/setters
as a scope. The "field names" of the fields/methods are used as the variable names.
- Author:
- Matthew Tropiano
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
containsValue
(String name) Checks if this contains a value by its variable name.boolean
getValue
(String name, ScriptValue out) Gets the corresponding value for a variable name.boolean
isEmpty()
Checks if this resolver maintains no values.boolean
isReadOnly
(String name) Checks if an existing value is read-only.void
setValue
(String name, ScriptValue value) Sets a key-value pair.int
size()
-
Constructor Details
-
ObjectVariableResolver
Creates a new resolver for this object.- Parameters:
instance
- the object instance to wrap.
-
-
Method Details
-
getInstance
- Returns:
- the wrapped instance.
-
getValue
Description copied from interface:ScriptVariableResolver
Gets the corresponding value for a variable name. Changing the returned value does not change the value, unless it is a reference type like a map or list.- Specified by:
getValue
in interfaceScriptVariableResolver
- Parameters:
name
- the variable name.out
- the destination variable for the value.- Returns:
- true if a corresponding value was fetched into out, false if not. If false, out is set to the null value.
-
setValue
Description copied from interface:ScriptVariableResolver
Sets a key-value pair. This should fail if the provided name corresponds to a read-only variable.- Specified by:
setValue
in interfaceScriptVariableResolver
- Parameters:
name
- the variable name.value
- the corresponding value.- See Also:
-
containsValue
Description copied from interface:ScriptVariableResolver
Checks if this contains a value by its variable name.- Specified by:
containsValue
in interfaceScriptVariableResolver
- Parameters:
name
- the variable name.- Returns:
- true if so, false if not.
-
isReadOnly
Description copied from interface:ScriptVariableResolver
Checks if an existing value is read-only.- Specified by:
isReadOnly
in interfaceScriptVariableResolver
- Parameters:
name
- the variable name.- Returns:
- true if so, false if not.
-
isEmpty
public boolean isEmpty()Description copied from interface:ScriptVariableResolver
Checks if this resolver maintains no values.- Specified by:
isEmpty
in interfaceScriptVariableResolver
- Returns:
- true if so, false if not.
-
size
public int size()- Specified by:
size
in interfaceScriptVariableResolver
- Returns:
- the amount of values that this maintains.
-