/** * Specify default values. To specify an empty * default value, use {@link #emptyDefaultValue()}. * * @param head First value * @param tail Rest of the values * * @return The same builder */ @SuppressWarnings("unchecked") public GenericCollectionPropertyBuilder<V, C> defaultValues(V head, V... tail) { List<V> tmp = new ArrayList<>(tail.length + 1); tmp.add(head); tmp.addAll(Arrays.asList(tail)); return super.defaultValue(getDefaultValue(tmp)); }
/** * Specify that the default value is an empty collection. * * @return The same builder */ public GenericCollectionPropertyBuilder<V, C> emptyDefaultValue() { return super.defaultValue(getDefaultValue(Collections.<V>emptyList())); }
/** * Specify default values. To specify an empty * default value, use {@link #emptyDefaultValue()}. * * @param head First value * @param tail Rest of the values * * @return The same builder */ @SuppressWarnings("unchecked") public GenericCollectionPropertyBuilder<V, C> defaultValues(V head, V... tail) { List<V> tmp = new ArrayList<>(tail.length + 1); tmp.add(head); tmp.addAll(Arrays.asList(tail)); return super.defaultValue(getDefaultValue(tmp)); }
@SuppressWarnings("unchecked") @Override public PropertyDescriptor<C> build() { // Note: the unchecked cast is safe because pre-7.0.0, // we only allow building property descriptors for lists. // C is thus always List<V>, and the cast doesn't fail // Post-7.0.0, the multi-value property classes will be removed // and C will be the actual type parameter of the returned property // descriptor return (PropertyDescriptor<C>) new GenericMultiValuePropertyDescriptor<>( getName(), getDescription(), 0f, getDefaultValue(), getConstraints(), parser, multiValueDelimiter, type ); }
/** * Specify a default value. * * @param val List of values * * @return The same builder */ @SuppressWarnings("unchecked") public GenericCollectionPropertyBuilder<V, C> defaultValue(Collection<? extends V> val) { super.defaultValue(getDefaultValue(val)); return this; }
/** * Specify that the default value is an empty collection. * * @return The same builder */ public GenericCollectionPropertyBuilder<V, C> emptyDefaultValue() { return super.defaultValue(getDefaultValue(Collections.<V>emptyList())); }
@SuppressWarnings("unchecked") @Override public PropertyDescriptor<C> build() { // Note: the unchecked cast is safe because pre-7.0.0, // we only allow building property descriptors for lists. // C is thus always List<V>, and the cast doesn't fail // Post-7.0.0, the multi-value property classes will be removed // and C will be the actual type parameter of the returned property // descriptor return (PropertyDescriptor<C>) new GenericMultiValuePropertyDescriptor<>( getName(), getDescription(), 0f, getDefaultValue(), getConstraints(), parser, multiValueDelimiter, type ); }
/** * Specify a default value. * * @param val List of values * * @return The same builder */ @SuppressWarnings("unchecked") public GenericCollectionPropertyBuilder<V, C> defaultValue(Collection<? extends V> val) { super.defaultValue(getDefaultValue(val)); return this; }