Class FunctionUtils

java.lang.Object
io.openems.common.utils.FunctionUtils

public final class FunctionUtils extends Object
  • Method Details

    • doNothing

      public static void doNothing()
      Helper method to create empty Runnable or ThrowingRunnable.

      Usage:

       final Runnable runnable = FunctionUtils::doNothing;
       
       final ThrowingRunnable<Exception> runnable = FunctionUtils::doNothing;
       
    • doNothing

      public static <T> void doNothing(T t)
      Helper method to create empty Consumer or ThrowingConsumer.

      Usage:

       final Consumer<String> consumer = FunctionUtils::doNothing;
       
       final ThrowingConsumer<String, Exception> consumer = FunctionUtils::doNothing;
       
      Type Parameters:
      T - the type of the first input parameter
      Parameters:
      t - the first input parameter
    • doNothing

      public static <T, U> void doNothing(T t, U e)
      Helper method to create empty BiConsumer or ThrowingBiConsumer.

      Usage:

       final BiConsumer<String> consumer = FunctionUtils::doNothing;
       
       final ThrowingBiConsumer<String, Exception> consumer = FunctionUtils::doNothing;
       
      Type Parameters:
      T - the type of the first input parameter
      U - the type of the second input parameter
      Parameters:
      t - the first input parameter
      e - the second input parameter
    • supplier

      public static <T> Supplier<T> supplier(Supplier<T> supplier)
      Helper method to create a Supplier.

      Instead of an explicit type:

       final Supplier<String> provideString = () -> {
              return "";
       };
       

      ... an implicit type based on the return value can be used:

       final var provideString = supplier(() -> {
              return "";
       });
       
      Type Parameters:
      T - the type of results supplied by the created supplier
      Parameters:
      supplier - the created Supplier
      Returns:
      the created Supplier