Class Optional

java.lang.Object
org.apache.el.stream.Optional

public class Optional extends Object
Represents an optional value that may or may not be present.
  • Method Details

    • get

      public Object get() throws ELException
      Returns 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 Object orElse(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 Object orElseGet(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