Class ELOptional<T>

java.lang.Object
io.micronaut.el.stream.ELOptional<T>
Type Parameters:
T - The type of the value

@Internal public final class ELOptional<T> extends Object
The Optional implementation class described in the section 2.3.3.2 of the Jakarta Expression Language specification.
Since:
1.0
Author:
Denis Stepanov
  • Method Details

    • empty

      public static <T> ELOptional<T> empty()
      Type Parameters:
      T - The type of the value
      Returns:
      An empty optional
    • of

      public static <T> ELOptional<T> of(@Nullable T value)
      Type Parameters:
      T - The type of the value
      Parameters:
      value - The value, can be null
      Returns:
      An optional holding the value
    • isPresent

      public boolean isPresent()
      Returns:
      True if a value is present
    • get

      public T get()
      Returns:
      The value held by the optional
    • ifPresent

      public void ifPresent(jakarta.el.LambdaExpression consumer)
      Parameters:
      consumer - The consumer invoked with the value when it is present
    • ifPresent

      public void ifPresent(Consumer<? super T> consumer)
      Parameters:
      consumer - The consumer invoked with the value when it is present, as compiled from a lambda expression
    • orElse

      public @Nullable Object orElse(@Nullable Object other)
      Parameters:
      other - The value returned when the optional is empty
      Returns:
      The value held by the optional or the given value
    • orElseGet

      public @Nullable Object orElseGet(jakarta.el.LambdaExpression other)
      Parameters:
      other - The lambda expression invoked when the optional is empty
      Returns:
      The value held by the optional or the result of the lambda expression
    • orElseGet

      public @Nullable Object orElseGet(Supplier<?> other)
      Parameters:
      other - The supplier invoked when the optional is empty, as compiled from a lambda expression
      Returns:
      The value held by the optional or the supplied value
    • invokeOperation

      public @Nullable Object invokeOperation(jakarta.el.ELContext context, String name, Object[] arguments)
      Invokes one of the operations of this class, avoiding the reflective dispatch of the standard resolvers.
      Parameters:
      context - The context
      name - The name of the operation
      arguments - The arguments
      Returns:
      The result of the operation
    • equals

      public boolean equals(@Nullable Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object