Class Switch


  • public final class Switch
    extends Object
    Class to implement switch functionally based on an Object's class
    • Method Detail

      • switchType

        public static <T> void switchType​(Object object,
                                          Consumer... consumers)
        Method to implement a "switch" based on an Object's class
        Type Parameters:
        T - the return type
        Parameters:
        object - object
        consumers - consumers
      • switchCase

        public static <T> Consumer<T> switchCase​(Class<T> clazz,
                                                 Consumer<T> consumer)
        Method to implement a switch "case" based on an Object's class
        Type Parameters:
        T - the return type
        Parameters:
        clazz - clazz
        consumer - consumer
        Returns:
        the return value