Class Dummy


  • public class Dummy
    extends java.lang.Object
    A utility class to help create dummy stub functional interfaces
    • Constructor Summary

      Constructors 
      Constructor Description
      Dummy()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static Callback callback()
      Creates a dummy callback
      static <T> java.util.function.Consumer<T> consumer()
      Creates a dummy consumer
      static <T,​R>
      java.util.function.Function<T,​R>
      function()
      Creates a dummy function
      static java.lang.Runnable ifNull​(java.lang.Runnable r)
      Returns the given runnable object if it is not null.
      static <T> java.util.function.Consumer<T> ifNull​(java.util.function.Consumer<T> c)
      Returns the given consumer object if it is not null.
      static <T,​R>
      java.util.function.Function<T,​R>
      ifNull​(java.util.function.Function<T,​R> f)
      Returns the given function object if it is not null.
      static <T> java.util.function.Supplier<T> ifNull​(java.util.function.Supplier<T> s)
      Returns the given callback object if it is not null.
      static Callback ifNull​(Callback c)
      Returns the given callback object if it is not null.
      static java.lang.Runnable runnable()
      Creates a dummy runnable
      static <T> java.util.function.Supplier<T> supplier()
      Creates a dummy supplier
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Dummy

        public Dummy()
    • Method Detail

      • callback

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

        public static <T> java.util.function.Consumer<T> consumer()
        Creates a dummy consumer
        Returns:
        a dummy consumer
      • function

        public static <T,​R> java.util.function.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> java.util.function.Supplier<T> supplier()
        Creates a dummy supplier
        Type Parameters:
        T - the result type
        Returns:
        the supplier
      • runnable

        public static java.lang.Runnable runnable()
        Creates a dummy runnable
        Returns:
        the runnable
      • ifNull

        public static <T> java.util.function.Consumer<T> ifNull​(java.util.function.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 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> java.util.function.Function<T,​R> ifNull​(java.util.function.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> java.util.function.Supplier<T> ifNull​(java.util.function.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 java.lang.Runnable ifNull​(java.lang.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