Class If<T>

java.lang.Object
org.dmfs.jems2.optional.If<T>
All Implemented Interfaces:
Optional<T>

public final class If<T> extends Object implements Optional<T>
Optional decorator restrains the presence of another Optional with a specific (independent) condition.

Example


 // only finite recurrence sets have a last occurrence!
 Optional<DateTime> lastOccurrence = new If<>(new Not<>(recurrenceSet::isInfinite), new Last<>(recurrenceSet))
 
  • Constructor Details

  • Method Details

    • isPresent

      public boolean isPresent()
      Description copied from interface: Optional
      Returns whether the optional value is present.
      Specified by:
      isPresent in interface Optional<T>
    • value

      public T value()
      Description copied from interface: Optional
      Returns the optional value.
      Specified by:
      value in interface Optional<T>