Package org.apache.el.stream
Class Optional
- java.lang.Object
-
- org.apache.el.stream.Optional
-
public class Optional extends java.lang.ObjectRepresents an optional value that may or may not be present.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Objectget()Returns the contained value, or throws an exception if empty.voidifPresent(LambdaExpression le)If a value is present, invokes the given lambda with the value.java.lang.ObjectorElse(java.lang.Object other)Returns the contained value, or the given default value if empty.java.lang.ObjectorElseGet(java.lang.Object le)Returns the contained value, or the result of evaluating the given lambda if empty.
-
-
-
Method Detail
-
get
public java.lang.Object get() throws ELExceptionReturns the contained value, or throws an exception if empty.- Returns:
- The contained value
- Throws:
ELException- if the value is not present
-
ifPresent
public void ifPresent(LambdaExpression le)
If a value is present, invokes the given lambda with the value.- Parameters:
le- The lambda expression to invoke
-
orElse
public java.lang.Object orElse(java.lang.Object other)
Returns the contained value, or the given default value if empty.- Parameters:
other- The default value- Returns:
- The contained value or the default
-
orElseGet
public java.lang.Object orElseGet(java.lang.Object le)
Returns the contained value, or the result of evaluating the given lambda if empty.- Parameters:
le- The lambda expression or already-evaluated value- Returns:
- The contained value or the result of the lambda
-
-