Interface ObjectUtils


public interface ObjectUtils
  • Method Summary

    Static Methods
    Modifier and Type
    Method
    Description
    static <T> T
    doWith(T object, @NotNull Consumer<? super @NotNull T> block)
     
    static <T, R> R
    mapWith(T object, @NotNull Function<? super @NotNull T,? extends R> block)
     
    static <T, R> R
    nn(T object, @NotNull Function<? super @NotNull T,? extends R> getter)
     
    static <T, R> R
    nn(T object, @NotNull Function<? super @NotNull T,? extends R> getter1, @NotNull Function<? super @NotNull T,? extends R> getter2)
     
    static <T, R> R
    nnOr(T object, @NotNull Function<? super @NotNull T,? extends R> getter1, @NotNull Supplier<? extends R> or)
     
  • Method Details

    • nn

      @Contract("null, _ -> null") @Nullable static <T, R> R nn(@Nullable T object, @NotNull @NotNull Function<? super @NotNull T,? extends R> getter)
      Returns:
      result of the specified getter if the specified object is non-null else null.
    • nn

      @Contract("null, _, _ -> null") @Nullable static <T, R> R nn(@Nullable T object, @NotNull @NotNull Function<? super @NotNull T,? extends R> getter1, @NotNull @NotNull Function<? super @NotNull T,? extends R> getter2)
      Returns:
      result of the first getter that gives non-null result if the specified object is non-null else null.
    • nnOr

      @Nullable static <T, R> R nnOr(@Nullable T object, @NotNull @NotNull Function<? super @NotNull T,? extends R> getter1, @NotNull @NotNull Supplier<? extends R> or)
    • doWith

      @Contract("!null, _ -> !null; null, _ -> null") static <T> T doWith(T object, @NotNull @NotNull Consumer<? super @NotNull T> block)
      Returns:
      the specified object after calling the specified block on it
    • mapWith

      @Contract("null, _ -> null") static <T, R> R mapWith(T object, @NotNull @NotNull Function<? super @NotNull T,? extends R> block)
      Returns:
      the specified object after calling the specified block on it