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

public abstract class AbstractController<T extends Removable> extends Object implements Iterable<T>
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 Details

    • AbstractController

      public AbstractController()
  • Method Details

    • process

      public abstract void process(T e)
    • update

      public void update()
    • contains

      public boolean contains(Object t)
      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

      public boolean add(T t)
      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

      public boolean add(T t, ControllerLayer layer)
      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

      public boolean addAll(Collection<T> c)
      Adds all elements to the controller, if they are not already added.
      Parameters:
      c - Collection to add.
      Returns:
      true, if this was modified.
    • addAll

      public boolean addAll(Collection<T> c, ControllerLayer layer)
      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

      public boolean remove(T t)
      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

      public void clearLayer(ControllerLayer layer)
      Removes all elements in the specific layer.
    • iterator

      public Iterator<T> iterator()
      Specified by:
      iterator in interface Iterable<T extends Removable>
      Returns:
      An iterator.
    • size

      public int size()
    • forEach

      public void forEach(Consumer<? super T> action)
      Specified by:
      forEach in interface Iterable<T extends Removable>
    • toString

      public String toString()
      Overrides:
      toString in class Object