/** * Be aware that when using this method you might have to deal with <code>null</code> values when calling {@link * #getValue()}. That's why this method is deprecated * * @deprecated use {@link #buildRequired()}, {@link #buildWithDefault(Object)} or {@link #buildOptional()}. The * only valid use of this method is if {@link #buildOptional()} would be the semantically correct option but you * are not using Java 8+. */ @Deprecated public ConfigurationOption<T> build() { return new ConfigurationOption<T>(dynamic, sensitive, key, label, description, defaultValue, configurationCategory, valueConverter, valueType, Arrays.asList(tags), required, changeListeners, validators, Arrays.asList(aliasKeys), validOptions); }
/** * Builds the option and marks it as not required * * <p> Use this method if setting this option is not required and to express that it may be <code>null</code>. * </p> */ public ConfigurationOption<Optional<T>> buildOptional() { required = false; final List<ChangeListener<Optional<T>>> optionalChangeListeners = new ArrayList<ChangeListener<Optional<T>>>(changeListeners.size()); for (ChangeListener<T> changeListener : changeListeners) { optionalChangeListeners.add(new ChangeListener.OptionalChangeListenerAdapter<T>(changeListener)); } final List<Validator<Optional<T>>> optionalValidators = new ArrayList<Validator<Optional<T>>>(validators.size()); for (Validator<T> validator : validators) { optionalValidators.add(new Validator.OptionalValidatorAdapter<T>(validator)); } return new ConfigurationOption<Optional<T>>(dynamic, sensitive, key, label, description, java.util.Optional.ofNullable(defaultValue), configurationCategory, new OptionalValueConverter<T>(valueConverter), java.util.Optional.class, Arrays.asList(this.tags), required, optionalChangeListeners, optionalValidators, Arrays.asList(aliasKeys), validOptions); }