Interface Ordered<E extends Element, C extends HasItems<E,C,S>, S extends HasIdentifier<? extends HTMLElement, ?>>
- Type Parameters:
E- the type of the main elementC- the type of the main componentS- the type of components being ordered
- All Superinterfaces:
HasItems<E,C, S>, IsElement<E>, Iterable<S>, TypedBuilder<E, C>
- All Known Implementing Classes:
DataList, DescriptionList, FinderColumn, List, MenuList, SimpleList, SimpleListGroup, Tbody
public interface Ordered<E extends Element, C extends HasItems<E,C,S>, S extends HasIdentifier<? extends HTMLElement, ?>>
extends HasItems<E,C,S>
The Ordered interface maintains its elements in a specific order. It extends the C,S>, S extends HasIdentifier<? extends HTMLElement, ?>> attribute. The order is maintained as elements are added to the
component.
HasItems interface. By default, the
order is determined by the defaultOrder() method which in turn determines the order based on the elements data
"order"<E extends Element, C extends HasItems<E,
If you want to use this feature, call ordered() resp. ordered(Comparator) on the builder. It is useful when
items are added asynchronously, and you want to visually maintain an order of items as they're added. If you know all items
in advance, it might be more performant if you sort them beforehand.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringA constant representing the key used to define the dataset attribute for ordering elements. -
Method Summary
Modifier and TypeMethodDescriptiondefault voidaddOrdered(ElementContainerMethods<?, ?> container, S item) Adds an item to the specified container in a predefined order.Retrieves the comparator used for ordering elements in a component.default Comparator<S> default Cordered()Orders the elements contained in the component using the default comparator.ordered(Comparator<S> comparator) Orders the elements contained in the component using the specified comparator.Methods inherited from interface HasItems
add, addItem, addItems, clear, contains, isEmpty, item, items, onAdd, onRemove, onUpdate, removeItem, replaceItemElement, size, updateItem, updateItem, updateItemMethods inherited from interface Iterable
forEach, iterator, spliteratorMethods inherited from interface TypedBuilder
that
-
Field Details
-
DATA_ORDER
A constant representing the key used to define the dataset attribute for ordering elements. It is commonly used in methods that deal with arranging or sorting elements based on a predefined structure or comparator. TheDATA_ORDERvalue, when used as an attribute key, indicates the sequence or arrangement of the associated data.- See Also:
-
-
Method Details
-
addOrdered
Adds an item to the specified container in a predefined order. If a comparator is provided, the order is determined based on the comparator; otherwise, the item is added directly to the container.- Parameters:
container- the container to which the item should be addeditem- the item to be added to the container
-
defaultOrder
-
ordered
Orders the elements contained in the component using the default comparator. The default comparator is based on the "order"<E extends Element, C extends HasItems<E,C, S>, S extends HasIdentifier<? extends HTMLElement, ?>> dataset attribute of the elements. - Returns:
- the builder instance with the elements ordered
-
ordered
Orders the elements contained in the component using the specified comparator. The comparator determines the order in which the elements are arranged.- Parameters:
comparator- the comparator used to define the ordering of the elements- Returns:
- the builder instance with the elements ordered
-
comparator
Comparator<S> comparator()Retrieves the comparator used for ordering elements in a component.- Returns:
- the comparator that determines the order of elements
-