/** * 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; }
/** Returns the value, asserting it has been set. */ T getDefaultValue() { if (!isDefaultValueSet()) { throw new IllegalArgumentException("A default value must be provided"); } return defaultValue; }
/** * Require that the given constraint be fulfilled on each item of the * value of this property. This is a convenient shorthand for * {@code require(constraint.toCollectionConstraint())}. * * @param constraint Constraint to impose on the items of the collection value * * @return The same builder */ public GenericCollectionPropertyBuilder<V, C> requireEach(PropertyConstraint<? super V> constraint) { return super.require(constraint.toCollectionConstraint()); }
/** * 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())); }
/** Returns the value, asserting it has been set. */ T getDefaultValue() { if (!isDefaultValueSet()) { throw new IllegalArgumentException("A default value must be provided"); } return defaultValue; }
/** * Require that the given constraint be fulfilled on each item of the * value of this property. This is a convenient shorthand for * {@code require(constraint.toCollectionConstraint())}. * * @param constraint Constraint to impose on the items of the collection value * * @return The same builder */ public GenericCollectionPropertyBuilder<V, C> requireEach(PropertyConstraint<? super V> constraint) { return super.require(constraint.toCollectionConstraint()); }
/** * 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 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 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)); }