Class Dummy

java.lang.Object
utility.function.Dummy

public class Dummy extends Object
A utility class to help create dummy stub functional interfaces
  • Constructor Details

    • Dummy

      public Dummy()
  • Method Details

    • callback

      public static Callback callback()
      Creates a dummy callback
      Returns:
      a dummy callback
    • consumer

      public static <T> Consumer<T> consumer()
      Creates a dummy consumer
      Returns:
      a dummy consumer
    • biConsumer

      public static <T, U> BiConsumer<T,U> biConsumer()
      Creates a dummy consumer
      Returns:
      a dummy consumer
    • function

      public static <T, R> Function<T,R> function()
      Creates a dummy function
      Type Parameters:
      T - the input type
      R - the result type
      Returns:
      the function
    • supplier

      public static <T> Supplier<T> supplier()
      Creates a dummy supplier
      Type Parameters:
      T - the result type
      Returns:
      the supplier
    • runnable

      public static Runnable runnable()
      Creates a dummy runnable
      Returns:
      the runnable
    • predicate

      public static <T> Predicate<T> predicate()
      Creates a dummy Predicate that always returns true.
      Type Parameters:
      T - the type of the value being tested
      Returns:
      the predicate that always returns true
    • biPredicate

      public static <T, U> BiPredicate<T,U> biPredicate()
      Creates a dummy BiPredicate that always returns true.
      Type Parameters:
      T - the type of the first argument to the predicate
      U - the type of the second argument the predicate
      Returns:
      the BiPredicate that always returns true
    • ifNull

      public static <T> Consumer<T> ifNull(Consumer<T> c)
      Returns the given consumer object if it is not null. Otherwise, a consumer() is returned. This is useful to avoid using null.
      Parameters:
      c - the consumer function to check for null
      Returns:
      a non-null consumer
    • ifNull

      public static <T, U> BiConsumer<T,U> ifNull(BiConsumer<T,U> c)
      Returns the given consumer object if it is not null. Otherwise, a biConsumer() is returned. This is useful to avoid using null.
      Parameters:
      c - the consumer function to check for null
      Returns:
      a non-null consumer
    • ifNull

      public static Callback ifNull(Callback c)
      Returns the given callback object if it is not null. Otherwise, a callback() is returned. This is useful to avoid using null.
      Parameters:
      c - the callback function to check for null
      Returns:
      a non-null callback function
    • ifNull

      public static <T, R> Function<T,R> ifNull(Function<T,R> f)
      Returns the given function object if it is not null. Otherwise, a function() is returned. This is useful to avoid using null.
      Type Parameters:
      T - the input type
      R - the result type
      Parameters:
      f - the function to check for null
      Returns:
      a non-null function
    • ifNull

      public static <T> Supplier<T> ifNull(Supplier<T> s)
      Returns the given callback object if it is not null. Otherwise, a callback() is returned. This is useful to avoid using null.
      Parameters:
      s - the supplier function to check for null
      Returns:
      a non-null supplier
    • ifNull

      public static Runnable ifNull(Runnable r)
      Returns the given runnable object if it is not null. Otherwise, a runnable() is returned. This is useful to avoid using null.
      Parameters:
      r - the runnable function to check for null
      Returns:
      a non-null runnable
    • ifNull

      public static <T> Predicate<T> ifNull(Predicate<T> p)
      Returns the given Predicate object if it is not null. Otherwise, a predicate() (which always returns true) is returned. This is useful to avoid using null.
      Parameters:
      p - the predicate function to check for null
      Returns:
      a non-null predicate
    • ifNull

      public static <T, U> BiPredicate<T,U> ifNull(BiPredicate<T,U> p)
      Returns the given BiPredicate object if it is not null. Otherwise, a biPredicate() (which always returns true) is returned. This is useful to avoid using null.
      Parameters:
      p - the predicate function to check for null
      Returns:
      a non-null predicate