< prev index next >

src/java.base/share/classes/java/util/OptionalInt.java

Print this page

        

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.  Oracle designates this

@@ -138,10 +138,20 @@
     public boolean isPresent() {
         return isPresent;
     }
 
     /**
+     * If a value is not present, returns {@code true}, otherwise
+     * {@code false}.
+     *
+     * @return {@code true} if a value is not present, otherwise {@code false}
+     */
+    public boolean isEmpty() {
+        return !isPresent;
+    }
+
+    /**
      * If a value is present, performs the given action with the value,
      * otherwise does nothing.
      *
      * @param action the action to be performed, if a value is present
      * @throws NullPointerException if value is present and the given action is
< prev index next >