Class ListAdder<TYPE_ELEMENT>

java.lang.Object
xyz.ronella.trivial.decorator.ListAdder<TYPE_ELEMENT>
Type Parameters:
TYPE_ELEMENT - The type of object that the list will hold.

public class ListAdder<TYPE_ELEMENT> extends Object
A class the wraps a List to have add methods with condition.
Since:
2.10.0
  • Constructor Details

    • ListAdder

      public ListAdder(List<TYPE_ELEMENT> list)
      Creates an instance of ListAdder
      Parameters:
      list - An instance of List to wrap.
  • Method Details

    • add

      public boolean add(BooleanSupplier when, TYPE_ELEMENT element)
      Add element to a wrapped list.
      Parameters:
      when - The logic that must return true to add the element.
      element - Specified in List.add
      Returns:
      Specified in List.add
    • add

      public boolean add(BooleanSupplier when, Supplier<TYPE_ELEMENT> generateElement)
      Add element to a wrapped list.
      Parameters:
      when - The logic that must return true to add the element.
      generateElement - The logic that will generate the element.
      Returns:
      Specified in List.add
    • add

      public boolean add(TYPE_ELEMENT element)
      Add element to a wrapped list. Added for convenience.
      Parameters:
      element - Specified in List.add
      Returns:
      Specified in List.add
    • add

      public boolean add(Supplier<TYPE_ELEMENT> generateElement)
      Add element to a wrapped list.
      Parameters:
      generateElement - The logic that will generate the element.
      Returns:
      Specified in List.add
    • addAll

      public boolean addAll(BooleanSupplier when, Collection<? extends TYPE_ELEMENT> elements)
      Add elements to a wrapped list.
      Parameters:
      when - The logic that must return true to add the elements.
      elements - Specified in List.addAll
      Returns:
      Specified in List.addAll
    • addAll

      public boolean addAll(BooleanSupplier when, Supplier<Collection<? extends TYPE_ELEMENT>> generateElements)
      Add elements to a wrapped list.
      Parameters:
      when - The logic that must return true to add the elements.
      generateElements - The logic that will generate the elements.
      Returns:
      Specified in List.addAll
    • addAll

      public boolean addAll(Collection<? extends TYPE_ELEMENT> elements)
      Add elements to a wrapped list. Added for convenience.
      Parameters:
      elements - Specified in List.addAll
      Returns:
      Specified in List.addAll
    • addAll

      public boolean addAll(Supplier<Collection<? extends TYPE_ELEMENT>> generateElements)
      Add elements to a wrapped list.
      Parameters:
      generateElements - The logic that will generate the elements.
      Returns:
      Specified in List.addAll
    • add

      public void add(BooleanSupplier when, int index, TYPE_ELEMENT element)
      Add element to a specific index of the wrapped list.
      Parameters:
      when - The logic that must return true to add the element.
      index - Specified in List.add
      element - Specified in List.add
    • add

      public void add(BooleanSupplier when, int index, Supplier<TYPE_ELEMENT> generateElement)
      Add element to a specific index of the wrapped list.
      Parameters:
      when - The logic that must return true to add the element.
      index - Specified in List.add
      generateElement - The logic that will generate the element.
    • add

      public void add(int index, TYPE_ELEMENT element)
      Add element to a specific index of the wrapped list. Added for convenience.
      Parameters:
      index - Specified in List.add
      element - Specified in List.add
    • add

      public void add(int index, Supplier<TYPE_ELEMENT> generateElement)
      Add element to a specific index of the wrapped list.
      Parameters:
      index - Specified in List.add
      generateElement - The logic that will generate the element.
    • addAll

      public boolean addAll(BooleanSupplier when, int index, Collection<? extends TYPE_ELEMENT> elements)
      Add elements to a specified index of the wrapped list.
      Parameters:
      when - The logic that must return true to add the elements.
      index - Specified in List.add
      elements - Specified in List.add
      Returns:
      Specified in List.addAll
    • addAll

      public boolean addAll(BooleanSupplier when, int index, Supplier<Collection<? extends TYPE_ELEMENT>> generateElements)
      Add elements to a specified index of the wrapped list.
      Parameters:
      when - The logic that must return true to add the elements.
      index - Specified in List.add
      generateElements - The logic that will generate the elements.
      Returns:
      Specified in List.addAll
    • addAll

      public boolean addAll(int index, Collection<? extends TYPE_ELEMENT> elements)
      Add elements to a specified index of the wrapped list. Added for convenience.
      Parameters:
      index - Specified in List.add
      elements - Specified in List.add
      Returns:
      Specified in List.addAll
    • addAll

      public boolean addAll(int index, Supplier<Collection<? extends TYPE_ELEMENT>> generateElements)
      Add elements to a specified index of the wrapped list. Added for convenience.
      Parameters:
      index - Specified in List.add
      generateElements - The logic that will generate the elements.
      Returns:
      Specified in List.addAll