5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 package jdk.vm.ci.options; 24 25 import java.io.*; 26 import java.util.*; 27 import java.util.Map.Entry; 28 29 /** 30 * An option value. 31 */ 32 public class OptionValue<T> { 33 /** 34 * Temporarily changes the value for an option. The {@linkplain OptionValue#getValue() value} of 35 * {@code option} is set to {@code value} until {@link OverrideScope#close()} is called on the 36 * object returned by this method. 37 * <p> 38 * Since the returned object is {@link AutoCloseable} the try-with-resource construct can be 39 * used: 40 * 41 * <pre> 42 * try (OverrideScope s = OptionValue.override(myOption, myValue) { 43 * // code that depends on myOption == myValue 44 * } 45 * </pre> 46 */ 47 public static OverrideScope override(OptionValue<?> option, Object value) { | 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 package jdk.vm.ci.options; 24 25 import java.io.PrintStream; 26 import java.util.ArrayList; 27 import java.util.Collection; 28 import java.util.Collections; 29 import java.util.Comparator; 30 import java.util.HashMap; 31 import java.util.Map; 32 import java.util.Map.Entry; 33 import java.util.Objects; 34 35 /** 36 * An option value. 37 */ 38 public class OptionValue<T> { 39 /** 40 * Temporarily changes the value for an option. The {@linkplain OptionValue#getValue() value} of 41 * {@code option} is set to {@code value} until {@link OverrideScope#close()} is called on the 42 * object returned by this method. 43 * <p> 44 * Since the returned object is {@link AutoCloseable} the try-with-resource construct can be 45 * used: 46 * 47 * <pre> 48 * try (OverrideScope s = OptionValue.override(myOption, myValue) { 49 * // code that depends on myOption == myValue 50 * } 51 * </pre> 52 */ 53 public static OverrideScope override(OptionValue<?> option, Object value) { |