/** * Constructs a new {@code EnumParam}, initialized to the default value. Limit the set of options * with the supplied {@code EnumSet}. * * @param name of the {@code Param} (max 72 chars) * @param info {@code String} for use in tooltips; a {@code null} value will be set to an empty * {@code String} (max 256 chars) * @param defaultValue of the {@code Param} * @param options a subset of the option type * @throws IllegalArgumentException if {@code name} is an empty string, {@code options} is empty, * or the {@code defaultValue} is not included in {@code options} */ DefaultEnumParam(String name, String info, E defaultValue, Set<E> options) { super(name, info, defaultValue); checkNotNull(options); checkArgument(!options.isEmpty(), "Options is empty"); checkArgument(options.contains(defaultValue), "Default missing from options"); this.options = Sets.immutableEnumSet(options); // init state state.addProperty(TYPE.toString(), ENUM.toString()); JsonArray stateOptions = new JsonArray(); for (E option : options) { stateOptions.add(new JsonPrimitive(option.name())); } state.add(OPTIONS.toString(), stateOptions); }
public <ENUM extends Enum<ENUM>> UnknownEnumValueException(Class<ENUM> enumeration, ENUM value) { super( String.format( "Unknown value <%s> for enumeration type <%s>", notNull(value.name()), notNull(enumeration.getCanonicalName()))); }