< prev index next >

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

Print this page




  36     private final OptionType<T> type;
  37     private final T defaultValue;
  38 
  39     /**
  40      * Constructs a new option key given a default value. Throws {@link IllegalArgumentException} if
  41      * no default {@link OptionType} could be {@link OptionType#defaultType(Object) resolved} for
  42      * the given type. The default value must not be <code>null</code>.
  43      *
  44      * @since 1.0
  45      */
  46     public OptionKey(T defaultValue) {
  47         Objects.requireNonNull(defaultValue);
  48         this.defaultValue = defaultValue;
  49         this.type = OptionType.defaultType(defaultValue);
  50         if (type == null) {
  51             throw new IllegalArgumentException("No default type specified for type " + defaultValue.getClass().getName() + ". Specify the option type explicitly to resolve this.");
  52         }
  53     }
  54 
  55     /**
  56      * Constructs a new option key given a default value and option key. The default value and the
  57      * type must not be <code>null</code>.
  58      *
  59      * @since 1.0
  60      */
  61     public OptionKey(T defaultValue, OptionType<T> type) {
  62         Objects.requireNonNull(defaultValue);
  63         Objects.requireNonNull(type);
  64         this.defaultValue = defaultValue;
  65         this.type = type;
  66     }
  67 
  68     /**
  69      * Returns the option type of this key.
  70      *
  71      * @since 1.0
  72      */
  73     public OptionType<T> getType() {
  74         return type;
  75     }
  76 
  77     /**
  78      * Returns the default value for this option.
  79      *
  80      * @since 1.0
  81      */
  82     public T getDefaultValue() {




  36     private final OptionType<T> type;
  37     private final T defaultValue;
  38 
  39     /**
  40      * Constructs a new option key given a default value. Throws {@link IllegalArgumentException} if
  41      * no default {@link OptionType} could be {@link OptionType#defaultType(Object) resolved} for
  42      * the given type. The default value must not be <code>null</code>.
  43      *
  44      * @since 1.0
  45      */
  46     public OptionKey(T defaultValue) {
  47         Objects.requireNonNull(defaultValue);
  48         this.defaultValue = defaultValue;
  49         this.type = OptionType.defaultType(defaultValue);
  50         if (type == null) {
  51             throw new IllegalArgumentException("No default type specified for type " + defaultValue.getClass().getName() + ". Specify the option type explicitly to resolve this.");
  52         }
  53     }
  54 
  55     /**
  56      * Constructs a new option key given a default value and option key.

  57      *
  58      * @since 1.0
  59      */
  60     public OptionKey(T defaultValue, OptionType<T> type) {

  61         Objects.requireNonNull(type);
  62         this.defaultValue = defaultValue;
  63         this.type = type;
  64     }
  65 
  66     /**
  67      * Returns the option type of this key.
  68      *
  69      * @since 1.0
  70      */
  71     public OptionType<T> getType() {
  72         return type;
  73     }
  74 
  75     /**
  76      * Returns the default value for this option.
  77      *
  78      * @since 1.0
  79      */
  80     public T getDefaultValue() {


< prev index next >