Class If

java.lang.Object
com.landawn.abacus.util.If

@Beta public final class If extends Object
This class is mainly designed for functional programming. Generally the traditional "if-else" or ternary operator: "? : " is preferred over this class.
Author:
HaiYang Li
  • Method Details

    • is

      public static If is(boolean b)
      Checks if is.
      Parameters:
      b -
      Returns:
    • not

      public static If not(boolean b)
      Parameters:
      b -
      Returns:
    • exists

      public static If exists(int index)
      true for index >= 0, false for index < 0.
      Parameters:
      index -
      Returns:
    • isEmpty

      public static If isEmpty(CharSequence s)
      Checks if is null or empty.
      Parameters:
      s -
      Returns:
    • isEmpty

      public static If isEmpty(boolean[] a)
      Checks if is null or empty.
      Parameters:
      a -
      Returns:
    • isEmpty

      public static If isEmpty(char[] a)
      Checks if is null or empty.
      Parameters:
      a -
      Returns:
    • isEmpty

      public static If isEmpty(byte[] a)
      Checks if is null or empty.
      Parameters:
      a -
      Returns:
    • isEmpty

      public static If isEmpty(short[] a)
      Checks if is null or empty.
      Parameters:
      a -
      Returns:
    • isEmpty

      public static If isEmpty(int[] a)
      Checks if is null or empty.
      Parameters:
      a -
      Returns:
    • isEmpty

      public static If isEmpty(long[] a)
      Checks if is null or empty.
      Parameters:
      a -
      Returns:
    • isEmpty

      public static If isEmpty(float[] a)
      Checks if is null or empty.
      Parameters:
      a -
      Returns:
    • isEmpty

      public static If isEmpty(double[] a)
      Checks if is null or empty.
      Parameters:
      a -
      Returns:
    • isEmpty

      public static If isEmpty(Object[] a)
      Checks if is null or empty.
      Parameters:
      a -
      Returns:
    • isEmpty

      public static If isEmpty(Collection<?> c)
      Checks if is null or empty.
      Parameters:
      c -
      Returns:
    • isEmpty

      public static If isEmpty(Map<?,?> m)
      Checks if is null or empty.
      Parameters:
      m -
      Returns:
    • isEmpty

      public static If isEmpty(PrimitiveList list)
      Checks if is null or empty.
      Parameters:
      list -
      Returns:
    • isEmpty

      public static If isEmpty(Multiset<?> s)
      Checks if is null or empty.
      Parameters:
      s -
      Returns:
    • isEmpty

      public static If isEmpty(LongMultiset<?> s)
      Checks if is null or empty.
      Parameters:
      s -
      Returns:
    • isEmpty

      public static If isEmpty(Multimap<?,?,?> m)
      Checks if is null or empty.
      Parameters:
      m -
      Returns:
    • isBlank

      public static If isBlank(CharSequence s)
      Checks if is null or empty or blank.
      Parameters:
      s -
      Returns:
    • notEmpty

      public static If notEmpty(CharSequence s)
      Not null or empty.
      Parameters:
      s -
      Returns:
    • notEmpty

      public static If notEmpty(boolean[] a)
      Not null or empty.
      Parameters:
      a -
      Returns:
    • notEmpty

      public static If notEmpty(char[] a)
      Not null or empty.
      Parameters:
      a -
      Returns:
    • notEmpty

      public static If notEmpty(byte[] a)
      Not null or empty.
      Parameters:
      a -
      Returns:
    • notEmpty

      public static If notEmpty(short[] a)
      Not null or empty.
      Parameters:
      a -
      Returns:
    • notEmpty

      public static If notEmpty(int[] a)
      Not null or empty.
      Parameters:
      a -
      Returns:
    • notEmpty

      public static If notEmpty(long[] a)
      Not null or empty.
      Parameters:
      a -
      Returns:
    • notEmpty

      public static If notEmpty(float[] a)
      Not null or empty.
      Parameters:
      a -
      Returns:
    • notEmpty

      public static If notEmpty(double[] a)
      Not null or empty.
      Parameters:
      a -
      Returns:
    • notEmpty

      public static If notEmpty(Object[] a)
      Not null or empty.
      Parameters:
      a -
      Returns:
    • notEmpty

      public static If notEmpty(Collection<?> c)
      Not null or empty.
      Parameters:
      c -
      Returns:
    • notEmpty

      public static If notEmpty(Map<?,?> m)
      Not null or empty.
      Parameters:
      m -
      Returns:
    • notEmpty

      public static If notEmpty(PrimitiveList list)
      Not null or empty.
      Parameters:
      list -
      Returns:
    • notEmpty

      public static If notEmpty(Multiset<?> s)
      Not null or empty.
      Parameters:
      s -
      Returns:
    • notEmpty

      public static If notEmpty(LongMultiset<?> s)
      Not null or empty.
      Parameters:
      s -
      Returns:
    • notEmpty

      public static If notEmpty(Multimap<?,?,?> m)
      Not null or empty.
      Parameters:
      m -
      Returns:
    • notBlank

      public static If notBlank(CharSequence s)
      Not null or empty or blank.
      Parameters:
      s -
      Returns:
    • thenDoNothing

      public If.OrElse thenDoNothing()
      Then do nothing.
      Returns:
    • then

      public <E extends Throwable> If.OrElse then(Throwables.Runnable<E> cmd) throws E
      Type Parameters:
      E -
      Parameters:
      cmd -
      Returns:
      Throws:
      E - the e
    • then

      public <U, E extends Throwable> If.OrElse then(U init, Throwables.Consumer<? super U,E> action) throws E
      Type Parameters:
      U -
      E -
      Parameters:
      init -
      action -
      Returns:
      Throws:
      E - the e
    • thenThrow

      public <E extends Throwable> If.OrElse thenThrow(Supplier<? extends E> exceptionSupplier) throws E
      Type Parameters:
      E -
      Parameters:
      exceptionSupplier -
      Returns:
      Throws:
      E - the e