Package me.sbasalaev

Class API

java.lang.Object
me.sbasalaev.API

public final class API extends Object
Useful utilities meant to be imported statically.
  • Method Summary

    Modifier and Type
    Method
    Description
    static <T> List<T>
    append(List<? extends T> list, T item)
    Returns list with given element appended to the end of given list.
    static <T> Traversable<T>
    chain(Traversable<? extends T>... elements)
    Chains several traversables together.
    static <T> List<T>
    concat(List<? extends T>... lists)
    Concatenates several lists together.
    static <T, R> Function<T,R>
    constant(R result)
    Constant function.
    static <T> List<T>
    Empty list.
    static <T> List<T>
    list(T... elements)
    List of given elements.
    static <T> Opt<T>
    maybe(@Nullable T value)
    Wraps value into optional.
    static <T> Opt<T>
    Empty optional.
    static <T> Set<T>
    set()
    Empty set.
    static <T> Set<T>
    set(T... elements)
    Set of given elements.
    static <T> Opt<T>
    some(T value)
    Non-empty optional.
    static int
    Returns sum of all numbers in a given traversable.
    static <T> T
    Throws NotImplementedError when evaluated.
    static <T> T
    TODO(String message)
    Throws NotImplementedError when evaluated.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • TODO

      public static <T> T TODO()
      Throws NotImplementedError when evaluated.
    • TODO

      public static <T> T TODO(String message)
      Throws NotImplementedError when evaluated.
    • constant

      public static <T, R> Function<T,R> constant(R result)
      Constant function.
    • none

      public static <T> Opt<T> none()
      Empty optional.
    • some

      public static <T> Opt<T> some(T value)
      Non-empty optional.
    • maybe

      public static <T> Opt<T> maybe(@Nullable T value)
      Wraps value into optional.
    • list

      public static <T> List<T> list()
      Empty list.
    • list

      @SafeVarargs public static <T> List<T> list(T... elements)
      List of given elements.
    • set

      public static <T> Set<T> set()
      Empty set.
    • set

      @SafeVarargs public static <T> Set<T> set(T... elements)
      Set of given elements.
    • chain

      @SafeVarargs public static <T> Traversable<T> chain(Traversable<? extends T>... elements)
      Chains several traversables together.
      See Also:
    • concat

      @SafeVarargs public static <T> List<T> concat(List<? extends T>... lists)
      Concatenates several lists together. The returned list is immutable and is not affected by changes to the original lists.
    • append

      public static <T> List<T> append(List<? extends T> list, T item)
      Returns list with given element appended to the end of given list. The returned list is immutable and is not affected by changes to the original list.
      Since:
      3.1
    • sum

      public static int sum(Traversable<Integer> numbers)
      Returns sum of all numbers in a given traversable.