Interface CollectionController
- All Superinterfaces:
Serializable
- All Known Implementing Classes:
CollectionField
Marker interface for all components that can control a collection.
Note: this is not generic in any way to allow reusing one controller among many components.
- Since:
- 2021-08-14
- Author:
- miki
-
Method Summary
Modifier and TypeMethodDescriptiondefault voidadd()Adds a new component at the end of current list.voidadd(int atIndex) Adds a new component at a specified position, moving subsequent elements by one.default booleanisEmpty()Checks if the collection is empty.default voidremove()Removes the last component.voidremove(int atIndex) Removes a component at given index.voidClears the collection and removes all elements from it.intsize()Returns the current size of the collection.
-
Method Details
-
size
int size()Returns the current size of the collection.- Returns:
- A non-negative number.
-
isEmpty
default boolean isEmpty()Checks if the collection is empty.- Returns:
trueifsize()returns0,falseotherwise.
-
removeAll
void removeAll()Clears the collection and removes all elements from it. -
add
void add(int atIndex) Adds a new component at a specified position, moving subsequent elements by one.- Parameters:
atIndex- Index to add at.
-
add
default void add() -
remove
void remove(int atIndex) Removes a component at given index. All subsequent components are moved forward by one.- Parameters:
atIndex- Index to remove component at.
-
remove
default void remove()Removes the last component. By default, it has the same effect as callingremove(int)withsize()- 1as parameter.
-