Class Objs

java.lang.Object
tech.deplant.java4ever.utils.Objs

public class Objs extends Object
  • Constructor Details

    • Objs

      public Objs()
  • Method Details

    • decode

      public static <OUT, IN> OUT decode(IN obj, IN compare, OUT then, OUT orElse)
    • isNull

      public static boolean isNull(Object obj)
    • isNotNull

      public static boolean isNotNull(Object obj)
    • equals

      public static boolean equals(Object a, Object b)
    • notNull

      public static <T> T notNull(T obj)
      Throws NullPointerException if object is null
      Type Parameters:
      T -
      Parameters:
      obj - Object that will be checked
      Returns:
      passed object
    • notNull

      public static <T> T notNull(T obj, String message)
      Throws NullPointerException with provided message if object is null
      Type Parameters:
      T -
      Parameters:
      obj - Object that will be checked
      message - Message for exception
      Returns:
      passed object
    • notNull

      public static <X extends Throwable, T> T notNull(T obj, Supplier<? extends X> exceptionSupplier) throws X
      Throws custom exception if object is null
      Type Parameters:
      T -
      Parameters:
      obj - Object that will be checked
      exceptionSupplier - Exception provider that will be thrown if object is null
      Returns:
      passed object
      Throws:
      X
    • notNullDo

      public static <T> void notNullDo(T obj, Consumer<T> action)
    • notNullElse

      public static <T> T notNullElse(T obj, T defaultObj)
      Replaces importing of Objects.requireNonNullElse() Returns defaultObj if obj is null
    • notNullElseLazy

      public static <T> T notNullElseLazy(T obj, Supplier<? extends T> supplier)
    • notNullReplaceElse

      public static <T, R> R notNullReplaceElse(T obj, R replaceObj, R defaultObj)
      If not null returns replaceObj, if null returns defaultObj analogue of NVL2() function in Oracle SQL
    • notNullReplaceElseLazy

      public static <T, R> R notNullReplaceElseLazy(T obj, Supplier<? extends R> replaceSupplier, Supplier<? extends R> defaultSupplier)