Commits

Sergei Vavinov  committed 93f2c95

Option#getOrElseF

  • Participants
  • Parent commits 9fed053

Comments (0)

Files changed (1)

File src/main/java/ru/yandex/bolts/collection/Option.java

     }
 
     /**
+     * Delegate to {@link #getOrElse(Object)}.
+     */
+    public static <U> Function<Option<U>, U> getOrElseF(final U fallback) {
+        return new Function<Option<U>, U>() {
+            public U apply(Option<U> us) {
+                return us.getOrElse(fallback);
+            }
+        };
+    }
+
+    /**
      * Delegate to {@link #some(Object)}.
      */
     public static <U> Function<U, Option<U>> someF() {