Class Accessible
- java.lang.Object
-
- pulse.util.UpwardsNavigable
-
- pulse.util.Group
-
- pulse.util.Accessible
-
- All Implemented Interfaces:
Serializable,Descriptive
- Direct Known Subclasses:
GeneralTask,PropertyHolder
public abstract class Accessible extends Group
An
Accessibleprovides Reflection-based read- and write-access to the underlying (usually declared as its own fields - but not necessarily) instances ofPropertyand a recursive access to otherAccessible, which may have a family relationship withthisAccessiblevia theUpwardsNavigableimplementation. It also defines its own list ofSaveables.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description Accessible()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description List<Accessible>accessibleChildren()Selects only thoseAccessibles, the parent of which isthis.List<Property>genericProperties()Tries to access the property getter methods in thisAccessible, which should be declared as no-argument methods with a specific return type.PropertygenericProperty(Property sameClass)Recursively searches for aPropertyfrom the non-unique list of generic properties in thisAccessibleby comparing its class tosameClass.getClass().Set<NumericProperty>numericProperties()Tries to access the property getter methods in thisAccessible, which should be declared as no-argument methods with a specific return type.NumericPropertynumericProperty(NumericPropertyKeyword type)Recursively searches for aNumericPropertyfrom the unique set of numeric properties in thisAccessibleby comparing itsNumericPropertyKeywordtotype.Propertyproperty(Property similar)Searches for aPropertyin thisAccessiblethat lookssimilarto the argument.abstract voidset(NumericPropertyKeyword type, NumericProperty property)An abstract method, which must be overriden to gain access over setting the values of all relevant (selected by the programmer)NumericProperties in subclasses ofAccessible.voidupdate(NumericProperty p)Set a NumericProperty contained in this Accessible or any of its accessible childern, using the NumericPropertyKeyword of the argument as identifier and its value.voidupdate(Property property)Runs recursive search for a property in thisAccessibleobject with the same identifier aspropertyand sets its value to the value of thepropertyparameter.Ifpropertyis aNumericProperty, uses itsNumericPropertyKeywordfor identification.-
Methods inherited from class pulse.util.Group
access, children, contents, getDescriptor, getSimpleName, subgroups
-
Methods inherited from class pulse.util.UpwardsNavigable
addHierarchyListener, describe, getHierarchyListeners, getParent, identify, initListeners, removeHierarchyListener, removeHierarchyListeners, setParent, specificAncestor, tellParent
-
-
-
-
Method Detail
-
property
public Property property(Property similar)
Searches for a
Propertyin thisAccessiblethat lookssimilarto the argument. Determines whether thesimilaris aNumericPropertyor a generic property and calls the suitable method in this class.- Parameters:
similar- a generic or a numericProperty- Returns:
- the matching property of this
Accessible
-
numericProperties
public Set<NumericProperty> numericProperties()
Tries to access the property getter methods in thisAccessible, which should be declared as no-argument methods with a specific return type.- Returns:
- This will return a unique
Set<NumericProperty>containing all instances ofNumericPropertybelonging to thisAccessible. This set will not contain any duplicate elements by definition.
-
genericProperties
public List<Property> genericProperties()
Tries to access the property getter methods in thisAccessible, which should be declared as no-argument methods with a specific return type.- Returns:
- This will return a
List<Property>containing all properties belonging to thisAccessible, which are not assignable from theNumericPropertyclass.
-
numericProperty
public NumericProperty numericProperty(NumericPropertyKeyword type)
Recursively searches for a
NumericPropertyfrom the unique set of numeric properties in thisAccessibleby comparing itsNumericPropertyKeywordtotype. This will search for this property through the children of this object, through the children of their children, etc.- Parameters:
type- the type of theNumericProperty.- Returns:
- the respective
NumericProperty, ornullif nothing is found. - See Also:
numericProperties()
-
genericProperty
public Property genericProperty(Property sameClass)
Recursively searches for a
Propertyfrom the non-unique list of generic properties in thisAccessibleby comparing its class tosameClass.getClass(). This will search for this property through the children of this object, through the children of their children, etc.- Parameters:
sameClass- the class identifying thisProperty.- Returns:
- the respective
Property, ornullif nothing is found. - See Also:
genericProperties()
-
set
public abstract void set(NumericPropertyKeyword type, NumericProperty property)
An abstract method, which must be overriden to gain access over setting the values of all relevant (selected by the programmer)
NumericProperties in subclasses ofAccessible. Typically this involves aswitchstatement that goes through the different options for thetypeand invokes differentset(...)methods to update the matchingNumericPropertywithproperty.- Parameters:
type- the type, which must be equal by definition toproperty.getType().property- the property, which contains new information.
-
update
public void update(Property property)
Runs recursive search for a property in thisAccessibleobject with the same identifier aspropertyand sets its value to the value of thepropertyparameter.Ifpropertyis aNumericProperty, uses itsNumericPropertyKeywordfor identification. For generic properties, callsattemptUpdate.- Parameters:
property- theProperty, which will update a similar property of thisAccessible.
-
update
public void update(NumericProperty p)
Set a NumericProperty contained in this Accessible or any of its accessible childern, using the NumericPropertyKeyword of the argument as identifier and its value.- Parameters:
p- a NumericProperty
-
accessibleChildren
public List<Accessible> accessibleChildren()
Selects only those
Accessibles, the parent of which isthis. Note that allAccessibles are required to explicitly adopt children by calling thesetParent()method.- Returns:
- a
Listof children that thisAccessiblehas adopted. - See Also:
Group.children()
-
-