< prev index next >

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

Print this page

        

*** 55,65 **** * * @since 1.0 */ public OptionType(String name, T defaultValue, Function<String, T> stringConverter, Consumer<T> validator) { Objects.requireNonNull(name); - Objects.requireNonNull(defaultValue); Objects.requireNonNull(stringConverter); Objects.requireNonNull(validator); this.name = name; this.stringConverter = stringConverter; this.defaultValue = defaultValue; --- 55,64 ----
*** 131,141 **** @Override public String toString() { return "OptionType[name=" + name + ", defaultValue=" + defaultValue + "]"; } ! private static Map<Class<?>, OptionType<?>> DEFAULTTYPES = new HashMap<>(); static { DEFAULTTYPES.put(Boolean.class, new OptionType<>("Boolean", false, new Function<String, Boolean>() { public Boolean apply(String t) { if ("true".equals(t)) { return Boolean.TRUE; --- 130,140 ---- @Override public String toString() { return "OptionType[name=" + name + ", defaultValue=" + defaultValue + "]"; } ! private static final Map<Class<?>, OptionType<?>> DEFAULTTYPES = new HashMap<>(); static { DEFAULTTYPES.put(Boolean.class, new OptionType<>("Boolean", false, new Function<String, Boolean>() { public Boolean apply(String t) { if ("true".equals(t)) { return Boolean.TRUE;
*** 198,212 **** })); } /** * Returns the default option type for a given value. Returns <code>null</code> if no default ! * option type is available for this Java type. * * @since 1.0 */ @SuppressWarnings("unchecked") ! public static <T> OptionType<T> defaultType(Object value) { ! return (OptionType<T>) DEFAULTTYPES.get(value.getClass()); } } --- 197,222 ---- })); } /** * Returns the default option type for a given value. Returns <code>null</code> if no default ! * option type is available for the Java type of this value. * * @since 1.0 */ @SuppressWarnings("unchecked") ! public static <T> OptionType<T> defaultType(T value) { ! return defaultType((Class<T>) value.getClass()); ! } ! ! /** ! * Returns the default option type for a class. Returns <code>null</code> if no default option ! * type is available for this Java type. ! * ! * @since 1.0 ! */ ! @SuppressWarnings("unchecked") ! public static <T> OptionType<T> defaultType(Class<T> clazz) { ! return (OptionType<T>) DEFAULTTYPES.get(clazz); } }
< prev index next >