Class Array<T>

java.lang.Object
org.ujorm.tools.common.Array<T>
All Implemented Interfaces:
Serializable

public class Array<T> extends Object implements Serializable
Methods to manage object arrays.

Usage

   Array array = Array.of('A', 'B', 'C', 'D', 'E');
   array.getFirst().orElse(undef);
   array.getLast().orElse(undef);
   array.getItem(9).orElse(undef);
   array.getItem(-2).orElse(undef);
   array.removeFirst();
   array.join('P', 'C')
 
Author:
Pavel Ponec
See Also:
  • Field Details

    • array

      protected final T[] array
  • Constructor Details

    • Array

      protected Array(@NotNull @NotNull T[] array)
  • Method Details

    • clone

      @NotNull public final @NotNull Array<T> clone()
      Overrides:
      clone in class Object
    • toArray

      @NotNull public @NotNull T[] toArray()
    • toList

      @NotNull public @NotNull List<T> toList()
    • stream

      @NotNull public @NotNull Stream<T> stream()
    • get

      @NotNull public @NotNull Optional<T> get(int i)
      Negative index value is supported, the index out of the range returns the null value.
    • getItem

      public T getItem(int i)
      Negative index is supported
    • getFirst

      @NotNull public @NotNull Optional<T> getFirst()
    • getLast

      @NotNull public @NotNull Optional<T> getLast()
    • removeFirst

      public Array<T> removeFirst()
    • subArray

      @NotNull public @NotNull Array<T> subArray(int from)
      Parameters:
      from - Negative value is supported
    • add

      @NotNull public @NotNull Array<T> add(@NotNull @NotNull T... toAdd)
      Add new items to the new Array
    • add

      @NotNull public @NotNull Array<T> add(@NotNull @NotNull Array<T> toAdd)
      Add new items to the new Array
    • isEmpty

      public boolean isEmpty()
    • size

      public int size()
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(@NotNull @NotNull Object obj)
      Overrides:
      equals in class Object
    • toString

      @NotNull public @NotNull String toString()
      Overrides:
      toString in class Object
    • of

      @NotNull public static <T> @NotNull Array<T> of(@NotNull @NotNull T... chars)
      Factory method