Optional
Last updated
Last updated
The optional class lets you handle possible null values in a programatic way, this way, you can avoid the use of multiple if
statements in your code. This plugin has been inspired by Optinal from Java 8.
Method
Description
of
Creates a new optional from a value
ofNullable
Creates a new optional from a value, if value is not present or null then it creates an empty instance of Optional.
ifPresent
Returns a boolean value. True if value is present (not null), otherwise false.
get
Returns value of Optional.
orElseGet
Tries to get the value
of the Optional instance, if it is not present then it returns a default value passed in the argument of the method
orElseThrows
Tries to get the value
of the Optional instance, if it is not present then it throws a custom error.