public class TreeObject<T extends TreeObject> extends Object implements Serializable
| Constructor and Description |
|---|
TreeObject()
Constructs an empty object without any children.
|
TreeObject(Set<T> childrenSet)
Constructs an object with a given set of children.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addChild(T child)
Adds an object as a child.
|
boolean |
belongsTo(Set<T> parentSet,
boolean recursive)
Returns a boolean indicating if this objects is a child of any of the members of given set.
|
boolean |
belongsTo(T parent,
boolean recursive)
Returns a boolean indicating if this object is a child of given object.
|
void |
clearChildren()
Remove all children objects.
|
boolean |
equals(Object obj) |
Set<T> |
getChildren() |
boolean |
hasChild(T child,
boolean recursive)
Returns a boolean indicating if given object is a child of this object.
|
boolean |
hasChildren() |
boolean |
hasChildren(Set<T> childrenSet,
boolean recursive)
Returns a boolean indicating if all elements of given set are children of this element.
|
int |
hashCode() |
void |
removeChild(T child)
Removes a direct child.
|
public TreeObject()
public TreeObject(Set<T> childrenSet) throws IllegalArgumentException
childrenSet - default children to be addedIllegalArgumentException - if children == null or children set contains nullpublic final boolean hasChildren()
public final boolean hasChild(T child, boolean recursive) throws IllegalArgumentException
child - object to be testedrecursive - define if children of children shall be searchedIllegalArgumentException - if child == nullpublic final boolean hasChildren(Set<T> childrenSet, boolean recursive) throws IllegalArgumentException
childrenSet - children to checkrecursive - define if children of children shall be searchedIllegalArgumentException - if childrenSet is nullpublic final boolean belongsTo(T parent, boolean recursive) throws IllegalArgumentException
parent - parent to testrecursive - define if parents of parents shall be searchedIllegalArgumentException - if parent == nullpublic final boolean belongsTo(Set<T> parentSet, boolean recursive) throws IllegalArgumentException
parentSet - parents to be searchedrecursive - define if parents of parents shall be searchedIllegalArgumentException - if parentSet == nullpublic final void addChild(T child) throws DuplicateException, IllegalArgumentException, CircularReferenceException
child - child to be addedDuplicateException - if given child was already added as a direct child of this object.IllegalArgumentException - if child == nullCircularReferenceException - if child.equals(this) or children (direct or indirect) of given child equals to thispublic final void removeChild(T child) throws IllegalArgumentException
child - child to be removed.IllegalArgumentException - if child == nullpublic final void clearChildren()
Copyright © 2015 Agapsys Tecnologia Ltda-ME. All rights reserved.