Package controller
Class AbstractController<T extends Removable>
java.lang.Object
controller.AbstractController<T>
- Type Parameters:
T
- generic type of elements to manage.
- All Implemented Interfaces:
Iterable<T>
- Direct Known Subclasses:
EntityController
,ScreenController
A controller manages elements of a certain type and is based on a layer system.
Layer system means: All elements are listed in ascending order according to the layers in this controller and in the order they are arranged in the layer.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
Adds the element with default layer (20) to this controller, if it is not already added.boolean
add
(T t, ControllerLayer layer) Adds the element with the specific layer to this controller, if it is not already added.boolean
addAll
(Collection<T> c) Adds all elements to the controller, if they are not already added.boolean
addAll
(Collection<T> c, ControllerLayer layer) Adds all elements with the specific layer to this controller, if they are not already added.void
clear()
Clears the entire controller (removes all elements).void
clearLayer
(ControllerLayer layer) Removes all elements in the specific layer.boolean
Returns true, if the element is in this controller.void
boolean
isEmpty()
Tests, if this controller has no elements.iterator()
abstract void
boolean
Removes the element from this controller, if it is in this controller.int
size()
toString()
void
update()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
spliterator
-
Constructor Details
-
AbstractController
public AbstractController()
-
-
Method Details
-
process
-
update
public void update() -
contains
Returns true, if the element is in this controller.- Parameters:
t
- Element to look for.- Returns:
- true, if the element is in this controller.
-
add
Adds the element with default layer (20) to this controller, if it is not already added.- Parameters:
t
- Element to add.- Returns:
- true, if this was successful.
-
add
Adds the element with the specific layer to this controller, if it is not already added.- Parameters:
t
- Element to add.layer
- Layer to add the element in.- Returns:
- true, if this was successful.
-
addAll
Adds all elements to the controller, if they are not already added.- Parameters:
c
- Collection to add.- Returns:
- true, if this was modified.
-
addAll
Adds all elements with the specific layer to this controller, if they are not already added.- Parameters:
c
- Collection to add.layer
- Layer to add the element in.- Returns:
- true, if this was modified.
-
remove
Removes the element from this controller, if it is in this controller.- Parameters:
t
- Element to remove.- Returns:
- true, if this was successful.
-
isEmpty
public boolean isEmpty()Tests, if this controller has no elements.- Returns:
- true, if empty.
-
clear
public void clear()Clears the entire controller (removes all elements). -
clearLayer
Removes all elements in the specific layer. -
iterator
-
size
public int size() -
forEach
-
toString
-