Class FunctionUtil

java.lang.Object
kr.toxicity.model.api.util.FunctionUtil

@Internal public final class FunctionUtil extends Object
Function util
  • Method Details

    • asSupplier

      @NotNull public static <T> @NotNull Supplier<T> asSupplier(@NotNull T t)
      Makes constant value as supplier.
      Type Parameters:
      T - supplier
      Parameters:
      t - value
      Returns:
      supplier that returns always the same object.
    • takeIf

      @Nullable public static <T> T takeIf(@NotNull T t, @NotNull @NotNull Predicate<T> predicate)
      Takes value if predicate is matched
      Type Parameters:
      T - type
      Parameters:
      t - t
      predicate - predicate
      Returns:
      t or null
    • throttleTick

      @NotNull public static <T> @NotNull Supplier<T> throttleTick(@NotNull @NotNull Supplier<T> supplier)
      Throttles this function by tick
      Type Parameters:
      T - type
      Parameters:
      supplier - target
      Returns:
      throttled function
    • throttleTick

      @NotNull public static <T> @NotNull Supplier<T> throttleTick(long tick, @NotNull @NotNull Supplier<T> supplier)
      Throttles this function by tick
      Type Parameters:
      T - type
      Parameters:
      tick - tick
      supplier - target
      Returns:
      throttled function
    • throttleTickFloat

      @NotNull public static @NotNull FloatSupplier throttleTickFloat(@NotNull @NotNull FloatSupplier supplier)
      Throttles this function by tick
      Parameters:
      supplier - target
      Returns:
      throttled function
    • throttleTickFloat

      @NotNull public static @NotNull FloatSupplier throttleTickFloat(long tick, @NotNull @NotNull FloatSupplier supplier)
      Throttles this function by tick
      Parameters:
      tick - tick
      supplier - target
      Returns:
      throttled function
    • throttleTickBoolean

      @NotNull public static @NotNull BooleanSupplier throttleTickBoolean(@NotNull @NotNull BooleanSupplier supplier)
      Throttles this function by tick
      Parameters:
      supplier - target
      Returns:
      throttled function
    • throttleTick

      @NotNull public static <T> @NotNull Predicate<T> throttleTick(@NotNull @NotNull Predicate<T> predicate)
      Throttles this function by tick
      Type Parameters:
      T - type
      Parameters:
      predicate - target
      Returns:
      throttled function
    • throttleTick

      @NotNull public static <T, R> @NotNull Function<T,R> throttleTick(@NotNull @NotNull Function<T,R> function)
      Throttles this function by tick
      Type Parameters:
      T - from
      R - return
      Parameters:
      function - target
      Returns:
      throttled function
    • throttleTick

      @NotNull public static <T, R> @NotNull Function<T,R> throttleTick(long tick, @NotNull @NotNull Function<T,R> function)
      Throttles this function by tick
      Type Parameters:
      T - from
      R - return
      Parameters:
      tick - tick
      function - target
      Returns:
      throttled function