Interface Ordered<E extends Element, B extends TypedBuilder<E,B>, S extends IsElement<? extends HTMLElement>>

Type Parameters:
E - the type of the main element
B - the type of the builder for chaining methods
S - the type of components being ordered
All Superinterfaces:
HasItems<E,B,S>, IsElement<E>, Iterable<S>, TypedBuilder<E,B>
All Known Implementing Classes:
DataList, DescriptionList, List, MenuList, SimpleList, SimpleListGroup, Tbody

public interface Ordered<E extends Element, B extends TypedBuilder<E,B>, S extends IsElement<? extends HTMLElement>> extends HasItems<E,B,S>
The Ordered interface can be implemented by components that maintain its elements in a specific order. It extends the 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, B extends TypedBuilder<E,B>, S extends IsElement<? extends HTMLElement>> attribute. The order is maintained as elements are added to the component.
  • Field Details

  • Method Details

    • addOrdered

      default void addOrdered(ElementContainerMethods<?,?> container, S item)
      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 added
      item - the item to be added to the container
    • defaultOrder

      default Comparator<S> defaultOrder()
      Provides a default comparator for ordering elements based on their "order"<E extends Element, B extends TypedBuilder<E,B>, S extends IsElement<? extends HTMLElement>> dataset value.
      Returns:
      a comparator that compares elements using the "order"<E extends Element, B extends TypedBuilder<E,B>, S extends IsElement<? extends HTMLElement>> attribute from their dataset
    • ordered

      default B ordered()
      Orders the elements contained in the component using the default comparator. The default comparator is based on the "order"<E extends Element, B extends TypedBuilder<E,B>, S extends IsElement<? extends HTMLElement>> dataset attribute of the elements.
      Returns:
      the builder instance with the elements ordered
    • ordered

      B ordered(Comparator<S> comparator)
      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