Module com.jongsoft.lang
Package com.jongsoft.lang.control
The control package contains flow control interfaces. These can be used to direct the logical flow of your code easier.
Current support control mechanisms
- Optional, for
null
safe access to elements - Try, for exception handling logic
- Equal, for logical equality building
The Optional is a functional representation of a value, or null
. In both cases the Optional itself
will be non null and allow functional access to its contents. It allows for handling when a value is present as
well as supporting control operations in case no value is present.
// Sample usage of the Optional
API.Option("one")
.ifPresent(System.out::println)
.orElse(() -> System.out.println("No value is present");
- Since:
- 0.0.1
-
Interface Summary Interface Description CheckedConsumer<T> CheckedFunction<U,T> CheckedRunner CheckedSupplier<T> Equal A control class to build an equality comparison.Optional<T> The Optional provides a functional way to detectnull
values without null reference checks or complicated logic throughout the code base.Optional.OrElse The OrElse interface is an extension to theOptional
interface.Try<T> The try interface allows for easier and more functional coding around exception handling.