Class Control


  • public class Control
    extends java.lang.Object
    • Constructor Summary

      Constructors 
      Constructor Description
      Control()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <T,​X>
      Equal
      Equal​(T left, X right)
      This operation will compare the left with the provided right and return the corresponding equality.
      static <T> Optional<T> Option()
      Will always return an empty optional.
      static <T> Optional<T> Option​(T value)
      Creates a new Optional representing the provided value.
      static Try<java.lang.Void> Try​(CheckedRunner runner)
      Attempt to execute the code in the CheckedRunner.
      static <T> Try<T> Try​(CheckedSupplier<T> supplier)
      Attempt to execute code that will return an entity, but may also result into an exception.
      • Methods inherited from class java.lang.Object

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

      • Control

        public Control()
    • Method Detail

      • Equal

        public static <T,​X> Equal Equal​(T left,
                                              X right)
        This operation will compare the left with the provided right and return the corresponding equality.
        Type Parameters:
        T - the type for left
        X - the type for right
        Parameters:
        left - the left value
        right - the right value
        Returns:
        the equality between left and right
      • Option

        public static <T> Optional<T> Option​(T value)
        Creates a new Optional representing the provided value.

        This method will allow null values.

        Type Parameters:
        T - the type of the value
        Parameters:
        value - the actual value
        Returns:
        an Optional representing the value
      • Option

        public static <T> Optional<T> Option()
        Will always return an empty optional.
        Type Parameters:
        T - the type of the value
        Returns:
        the empty optional
      • Try

        public static <T> Try<T> Try​(CheckedSupplier<T> supplier)
        Attempt to execute code that will return an entity, but may also result into an exception.
        Type Parameters:
        T - the type of entity that will be returned in case of success
        Parameters:
        supplier - the supplier that will return the entity
        Returns:
        either an Try with success set to true and a get returning the entity, or a Try with failure set to true and the get throwing the exception.
        Throws:
        java.lang.NullPointerException - in case the supplier is null
      • Try

        public static Try<java.lang.Void> Try​(CheckedRunner runner)
        Attempt to execute the code in the CheckedRunner. If the execution results into an exception then this call will return a Try with a failure result. Otherwise it will return an empty success Try.
        Parameters:
        runner - the code to execute with a try..catch construction
        Returns:
        A Try with success set to true if the execution went without exceptions, otherwise it will return a Try with a failure set to true.
        Throws:
        java.lang.NullPointerException - in case the runner is null