< prev index next >

src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.options/src/org/graalvm/compiler/options/OptionKey.java

Print this page

        

@@ -139,10 +139,22 @@
         assert checkDescriptorExists();
         return values.get(this);
     }
 
     /**
+     * Gets the value of this option in {@code values} if it is present, otherwise
+     * {@link #getDefaultValue()}.
+     */
+    @SuppressWarnings("unchecked")
+    public T getValueOrDefault(EconomicMap<OptionKey<?>, Object> values) {
+        if (!values.containsKey(this)) {
+            return defaultValue;
+        }
+        return (T) values.get(this);
+    }
+
+    /**
      * Sets the value of this option in a given map. The
      * {@link #onValueUpdate(EconomicMap, Object, Object)} method is called once the value is set.
      *
      * @param values map of option values
      * @param v the value to set for this key in {@code map}
< prev index next >