provides generic support for operations requiring type-dependent
access to the siblings of a child object.
An adapter may be obtained by Tree.getSibling(child,parent) where child
and parent may be an instance or class.
Thereafter the adapter may be used to obtain the siblings by getSiblings().
Method Summary |
java.util.List<? super C> |
getChildren(P parent)
Return all child class children of parent. |
java.lang.String |
getLabel(C child)
Get the label (name/text/whetever) of the child. |
java.lang.Class<P> |
getParentClass()
Return the parent class |
java.util.List<? super C> |
getSiblings(C child)
Return all siblings of and with the same class as child. |
boolean |
hasLabel()
Test whether the child class has a label field. |
int |
removeChild(C child,
P parent)
Remove the child from the parent returning the non-negative index at which the
removal was made, or -ve if not found. |
void |
setLabel(C child,
java.lang.String label)
Set the label (name/text/whetever) of the child. |
getChildren
java.util.List<? super C> getChildren(P parent)
- Return all child class children of parent. Note that the returned list
is the parenmt's list if the parent happens to maintain a suitable list,
otherwise a temporary list is constructed for the return. Changes to
the temporary do not affect the parent.
- Parameters:
parent
- parent of required children
- Returns:
- the non-null but possibly empty list of children
getLabel
java.lang.String getLabel(C child)
- Get the label (name/text/whetever) of the child.
- Parameters:
child
- providing the label
- Returns:
- the label
getParentClass
java.lang.Class<P> getParentClass()
- Return the parent class
- Returns:
- the parent class
getSiblings
java.util.List<? super C> getSiblings(C child)
- Return all siblings of and with the same class as child.
- Parameters:
child
-
- Returns:
- the siblings.
hasLabel
boolean hasLabel()
- Test whether the child class has a label field.
- Returns:
- true if getLabel() and setLabel() are useable.
removeChild
int removeChild(C child,
P parent)
- Remove the child from the parent returning the non-negative index at which the
removal was made, or -ve if not found.
- Parameters:
child
- child to removeparent
- expected parent of child
- Returns:
- removal index
setLabel
void setLabel(C child,
java.lang.String label)
- Set the label (name/text/whetever) of the child.
- Parameters:
child
- providing the labellabel
- the label