Class Nulls

java.lang.Object
io.rocketbase.commons.util.Nulls

public final class Nulls extends Object
shorten null checks
  • Constructor Details

    • Nulls

      public Nulls()
  • Method Details

    • notNull

      public static <T> T notNull(T value, T fallback)
      when value is null returns fallback
    • notNull

      public static String notNull(String value)
      returns empty string when value is null
    • notNull

      public static Boolean notNull(Boolean value)
      return false when value is null
    • notNull

      public static Long notNull(Long value)
      return 0 when value is null
    • notNull

      public static Integer notNull(Integer value)
      return 0 when value is null
    • notNull

      public static BigDecimal notNull(BigDecimal value)
      return BigDecimal.ZERO when value is null
    • notNull

      public static <T> List<T> notNull(List<T> value)
      in case of null value return's new ArrayList
    • notNull

      public static <T> Set<T> notNull(Set<T> value)
      in case of null value return's new HashSet
    • notNull

      public static <K, V> Map<K,V> notNull(Map<K,V> value)
      in case of null value return's new HashMap<K,V
    • accept

      public static <T> void accept(T value, Consumer<T> consumer)
      accept when value is not null
    • apply

      public static <T, R> R apply(T value, Function<T,R> function, R fallback)
      apply when value is not null
    • notEmpty

      public static String notEmpty(String value, String fallback)
      returns fallback when value is empty
    • notNull

      public static <TARGET, SOURCE> TARGET notNull(SOURCE value, Nulls.PropertyValueProvider<SOURCE,TARGET> provider, TARGET fallback)
    • notNull

      public static <SOURCE> String notNull(SOURCE value, Nulls.PropertyValueProvider<SOURCE,String> provider)
    • notEmpty

      public static <SOURCE> String notEmpty(SOURCE value, Nulls.PropertyValueProvider<SOURCE,String> provider, String fallback)
    • noneNullValue

      public static <T> boolean noneNullValue(T... values)
      return's true if all values are not null
      false in case one is null
    • anyNoneNullValue

      public static <T> boolean anyNoneNullValue(T... values)
      return's true if at least one of the values it not null