Package controller
Class AbstractController<T extends DungeonElement>
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractSet<E>
java.util.HashSet<E>
java.util.LinkedHashSet<T>
controller.AbstractController<T>
- Type Parameters:
T
- Type of elements to manage.
- All Implemented Interfaces:
Serializable
,Cloneable
,Iterable<T>
,Collection<T>
,Set<T>
- Direct Known Subclasses:
EntityController
,HUDController
public abstract class AbstractController<T extends DungeonElement>
extends LinkedHashSet<T>
implements Iterable<T>
A controller manages elements of a certain type and is based on a layer system.
- See Also:
-
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<? extends T> c) void
clear()
Clears the entire controller (removes all elements).void
clearLayer
(ControllerLayer layer) Removes all elements in the specific layer.clone()
boolean
Returns true, if the element is in this controller.boolean
containsAll
(Collection<?> c) boolean
void
int
hashCode()
boolean
isEmpty()
Tests, if this controller has no elements.iterator()
boolean
Removes the element from this controller, if it is in this controller.boolean
removeAll
(Collection<?> c) boolean
boolean
retainAll
(Collection<?> c) int
size()
stream()
Object[]
toArray()
<T1> T1[]
toArray
(IntFunction<T1[]> generator) <T1> T1[]
toArray
(T1[] a) toString()
void
update()
Updates all elements that are registered at this controller, removes deletable elements and calls the update and draw method for every registered element.
-
Constructor Details
-
AbstractController
public AbstractController()
-
-
Method Details
-
update
public void update()Updates all elements that are registered at this controller, removes deletable elements and calls the update and draw method for every registered element. -
contains
Returns true, if the element is in this controller.- Specified by:
contains
in interfaceCollection<T extends DungeonElement>
- Specified by:
contains
in interfaceSet<T extends DungeonElement>
- Overrides:
contains
in classHashSet<T extends DungeonElement>
- 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.- Specified by:
add
in interfaceCollection<T extends DungeonElement>
- Specified by:
add
in interfaceSet<T extends DungeonElement>
- Overrides:
add
in classHashSet<T extends DungeonElement>
- 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.
-
remove
Removes the element from this controller, if it is in this controller.- Specified by:
remove
in interfaceCollection<T extends DungeonElement>
- Specified by:
remove
in interfaceSet<T extends DungeonElement>
- Overrides:
remove
in classHashSet<T extends DungeonElement>
- Parameters:
t
- Element to remove.- Returns:
- true, if this was successful.
-
isEmpty
public boolean isEmpty()Tests, if this controller has no elements.- Specified by:
isEmpty
in interfaceCollection<T extends DungeonElement>
- Specified by:
isEmpty
in interfaceSet<T extends DungeonElement>
- Overrides:
isEmpty
in classHashSet<T extends DungeonElement>
- Returns:
- true, if empty.
-
clear
public void clear()Clears the entire controller (removes all elements).- Specified by:
clear
in interfaceCollection<T extends DungeonElement>
- Specified by:
clear
in interfaceSet<T extends DungeonElement>
- Overrides:
clear
in classHashSet<T extends DungeonElement>
-
clearLayer
Removes all elements in the specific layer. -
iterator
- Specified by:
iterator
in interfaceCollection<T extends DungeonElement>
- Specified by:
iterator
in interfaceIterable<T extends DungeonElement>
- Specified by:
iterator
in interfaceSet<T extends DungeonElement>
- Overrides:
iterator
in classHashSet<T extends DungeonElement>
- Returns:
- An unmodifiable iterator.
-
size
public int size()- Specified by:
size
in interfaceCollection<T extends DungeonElement>
- Specified by:
size
in interfaceSet<T extends DungeonElement>
- Overrides:
size
in classHashSet<T extends DungeonElement>
-
forEach
- Specified by:
forEach
in interfaceIterable<T extends DungeonElement>
-
toString
- Overrides:
toString
in classAbstractCollection<T extends DungeonElement>
-
spliterator
- Specified by:
spliterator
in interfaceCollection<T extends DungeonElement>
- Specified by:
spliterator
in interfaceIterable<T extends DungeonElement>
- Specified by:
spliterator
in interfaceSet<T extends DungeonElement>
- Overrides:
spliterator
in classLinkedHashSet<T extends DungeonElement>
-
clone
- Overrides:
clone
in classHashSet<T extends DungeonElement>
-
toArray
- Specified by:
toArray
in interfaceCollection<T extends DungeonElement>
- Specified by:
toArray
in interfaceSet<T extends DungeonElement>
- Overrides:
toArray
in classHashSet<T extends DungeonElement>
-
toArray
public <T1> T1[] toArray(T1[] a) - Specified by:
toArray
in interfaceCollection<T extends DungeonElement>
- Specified by:
toArray
in interfaceSet<T extends DungeonElement>
- Overrides:
toArray
in classHashSet<T extends DungeonElement>
-
equals
- Specified by:
equals
in interfaceCollection<T extends DungeonElement>
- Specified by:
equals
in interfaceSet<T extends DungeonElement>
- Overrides:
equals
in classAbstractSet<T extends DungeonElement>
-
hashCode
public int hashCode()- Specified by:
hashCode
in interfaceCollection<T extends DungeonElement>
- Specified by:
hashCode
in interfaceSet<T extends DungeonElement>
- Overrides:
hashCode
in classAbstractSet<T extends DungeonElement>
-
removeAll
- Specified by:
removeAll
in interfaceCollection<T extends DungeonElement>
- Specified by:
removeAll
in interfaceSet<T extends DungeonElement>
- Overrides:
removeAll
in classAbstractSet<T extends DungeonElement>
-
containsAll
- Specified by:
containsAll
in interfaceCollection<T extends DungeonElement>
- Specified by:
containsAll
in interfaceSet<T extends DungeonElement>
- Overrides:
containsAll
in classAbstractCollection<T extends DungeonElement>
-
addAll
- Specified by:
addAll
in interfaceCollection<T extends DungeonElement>
- Specified by:
addAll
in interfaceSet<T extends DungeonElement>
- Overrides:
addAll
in classAbstractCollection<T extends DungeonElement>
-
retainAll
- Specified by:
retainAll
in interfaceCollection<T extends DungeonElement>
- Specified by:
retainAll
in interfaceSet<T extends DungeonElement>
- Overrides:
retainAll
in classAbstractCollection<T extends DungeonElement>
-
toArray
- Specified by:
toArray
in interfaceCollection<T extends DungeonElement>
-
removeIf
- Specified by:
removeIf
in interfaceCollection<T extends DungeonElement>
-
stream
- Specified by:
stream
in interfaceCollection<T extends DungeonElement>
-
parallelStream
- Specified by:
parallelStream
in interfaceCollection<T extends DungeonElement>
-