Class ArcheTextObject
java.lang.Object
com.blackrook.archetext.ArcheTextObject
The object representation for all ArcheText objects and values.
ArcheText objects have types and can inherit values from one or more objects.
- Author:
- Matthew Tropiano
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new anonymous ArcheTextObject.ArcheTextObject(String type) Creates a new default ArcheTextObject with a type.ArcheTextObject(String type, String identity) Creates a new ArcheTextObject with a type and identity. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddParent(ArcheTextObject parent) Adds a parent to this object.<T> TapplyToObject(T object) Applies this object to an object bean / plain ol' Java object.voidcascade(ArcheTextObject addend) Adds the fields and lineage from another object to this object.voidClears the value of a field.booleancontainsLocal(String name) Returns true if this object (and only this object) contains a field.voidflatten()Flattens the hierarchy of this object, such that it has no parent references and its fields are all SET fields with the hierarchically-calculated results.Gets the value of a field, searching through its lineage if it doesn't exist in this one, combining values as necessary.<T> TGets the value of a field, searching through its lineage if it doesn't exist in this one, combining values as necessary.Returns all possible field names in this object's lineage.<T> TGets the value of a local field.getType()booleanboolean<T> TConverts the contents of this object to a new instance of an object bean / plain ol' Java object.voidpushParent(ArcheTextObject parent) Pushes a parent onto the top of the parent stack.booleanremoveParent(ArcheTextObject parent) Removes a parent from the parent stack.voidset(String name, Combinator combinator, Object value) Sets the value of a field.voidSets the value of a field.toString()
-
Constructor Details
-
ArcheTextObject
public ArcheTextObject()Creates a new anonymous ArcheTextObject. -
ArcheTextObject
Creates a new default ArcheTextObject with a type.- Parameters:
type- the object type name.
-
ArcheTextObject
-
-
Method Details
-
getType
- Returns:
- the type name of this object.
-
getIdentity
- Returns:
- the identity of this object.
-
getParents
- Returns:
- an Iterable of the object's parents, in order of precedence.
-
isAnonymous
public boolean isAnonymous()- Returns:
- true if this object has no type nor name, false otherwise.
-
isDefault
public boolean isDefault()- Returns:
- true if this object has a type but no name, false otherwise.
-
pushParent
Pushes a parent onto the top of the parent stack. The new parent is now the highest priority for inheritance.- Parameters:
parent- the parent to push.
-
addParent
Adds a parent to this object. The new parent is now the lowest priority for inheritance.- Parameters:
parent- the parent to add.
-
removeParent
Removes a parent from the parent stack.- Parameters:
parent- the parent to remove.- Returns:
- true if removed.
-
set
-
set
Sets the value of a field.- Parameters:
name- the name of the field to set.combinator- the value combinator for field inheritance.value- the value of the field.
-
clear
Clears the value of a field.- Parameters:
name- the name of the field to clear.
-
containsLocal
Returns true if this object (and only this object) contains a field.- Parameters:
name- the name of the field.- Returns:
- true if so, false if not.
-
getLocal
Gets the value of a local field. The field's value is taken from THIS OBJECT, not its parents.- Type Parameters:
T- the return type.- Parameters:
name- the name of the field.outputType- the output type to convert to.- Returns:
- the value converted to the desired type.
-
get
-
get
Gets the value of a field, searching through its lineage if it doesn't exist in this one, combining values as necessary.- Type Parameters:
T- the return type.- Parameters:
name- the name of the field.outputType- the output type to convert to.- Returns:
- the value converted to the desired type.
-
cascade
Adds the fields and lineage from another object to this object. NOTE: FieldCombinators from the object getting added come into effect when setting the values in this object.- Parameters:
addend- the object to add to this one.
-
flatten
public void flatten()Flattens the hierarchy of this object, such that it has no parent references and its fields are all SET fields with the hierarchically-calculated results. This object's contents will be changed. The parents themselves are not changed. -
getAvailableFieldNames
-
newObject
Converts the contents of this object to a new instance of an object bean / plain ol' Java object.This object is applied via the target object's public fields and setter methods.
For instance, if there is a member on this object called "color", its value will be applied via the public field "color" or the setter "setColor()". Public fields take precedence over setters.
- Type Parameters:
T- the return type.- Parameters:
clazz- the output class type.- Returns:
- the new object.
-
applyToObject
public <T> T applyToObject(T object) Applies this object to an object bean / plain ol' Java object.This object is applied via the target object's public fields and setter methods.
For instance, if there is a member on this object called "color", its value will be applied via the public field "color" or the setter "setColor()". Public fields take precedence over setters.
- Type Parameters:
T- the return type.- Parameters:
object- the target object.- Returns:
- the applied object itself.
-
fieldNameIterator
-
toString
-