Interface HasParents<T>
- Type Parameters:
T- The type of the parent objects.
public interface HasParents<T>
An interface for objects that can be part of a composite structure, allowing them
to maintain references to their parent or owner objects.
This is particularly useful in a scene graph or a composite geometry system where
child objects (e.g., a GPoint) need to notify their parent objects
(e.g., a GLine or GTri) of changes. By implementing this interface,
an object can track multiple parents that depend on its state.
- Author:
- Lehlogonolo Poole
-
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a parent to this object's set of parents.default voidaddParents(T... parents) A convenience method to add multiple parent objects at once.default voidRetrieves the set of all parent objects that this object belongs to.default booleanChecks if this object has at least one parent.voidremoveParent(T parent) Removes a parent from this object's set of parents.
-
Method Details
-
getParents
Retrieves the set of all parent objects that this object belongs to.- Returns:
- A
HashSetcontaining all parent objects. Using a Set ensures that a parent can only be added once.
-
addParent
Adds a parent to this object's set of parents.- Parameters:
parent- The parent object to add.
-
removeParent
Removes a parent from this object's set of parents.- Parameters:
parent- The parent object to remove.
-
addParents
A convenience method to add multiple parent objects at once.- Parameters:
parents- A varargs array of parent objects to add.
-
hasParent
default boolean hasParent()Checks if this object has at least one parent.- Returns:
trueif the set of parents is not empty,falseotherwise.
-
clearParents
default void clearParents()
-