- java.lang.Object
-
- com.jongsoft.lang.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>
EqualEqual(T left, X right)
This operation will compare theleft
with the providedright
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 newOptional
representing the provided value.static Try<java.lang.Void>
Try(CheckedRunner runner)
Attempt to execute the code in theCheckedRunner
.static <T> Try<T>
Try(CheckedSupplier<T> supplier)
Attempt to execute code that will return an entity, but may also result into an exception.
-
-
-
Method Detail
-
Equal
public static <T,X> Equal Equal(T left, X right)
This operation will compare theleft
with the providedright
and return the corresponding equality.- Type Parameters:
T
- the type for leftX
- the type for right- Parameters:
left
- the left valueright
- the right value- Returns:
- the equality between
left
andright
-
Option
public static <T> Optional<T> Option(T value)
Creates a newOptional
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 aTry
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 theCheckedRunner
. If the execution results into an exception then this call will return aTry
with a failure result. Otherwise it will return an empty successTry
.
-
-