Package net.sourceforge.pmd.properties
Class PropertyBuilder.GenericCollectionPropertyBuilder<V,C extends Iterable<V>>
java.lang.Object
net.sourceforge.pmd.properties.PropertyBuilder<PropertyBuilder.GenericCollectionPropertyBuilder<V,C>,C>
net.sourceforge.pmd.properties.PropertyBuilder.GenericCollectionPropertyBuilder<V,C>
- Type Parameters:
V- Component type of the collectionC- Collection type for the property being built
- Enclosing class:
- PropertyBuilder<B extends PropertyBuilder<B,
T>, T>
public static final class PropertyBuilder.GenericCollectionPropertyBuilder<V,C extends Iterable<V>>
extends PropertyBuilder<PropertyBuilder.GenericCollectionPropertyBuilder<V,C>,C>
Generic builder for a collection-valued property.
This class adds methods related to
defaultValue(Iterable)
to make its use more flexible. See e.g. defaultValues(Object, Object[]).
Note: this is designed to support arbitrary collections.
Pre-7.0.0, the only collections available from the PropertyFactory
are list types though.
- Author:
- Clément Fournier
- Since:
- 6.10.0
-
Nested Class Summary
Nested classes/interfaces inherited from class net.sourceforge.pmd.properties.PropertyBuilder
PropertyBuilder.GenericCollectionPropertyBuilder<V,C extends Iterable<V>>, PropertyBuilder.GenericPropertyBuilder<T>, PropertyBuilder.RegexPropertyBuilder -
Field Summary
Fields inherited from class net.sourceforge.pmd.properties.PropertyBuilder
isXPathAvailable, typeId -
Method Summary
Modifier and TypeMethodDescriptionbuild()Builds the descriptor and returns it.defaultValue(Iterable<? extends V> val) Specify a default value.defaultValues(V head, V... tail) Specify default values.Specify that the default value is an empty collection.require(PropertyConstraint<? super C> constraint) Add a constraint on the values that this property may take.requireEach(PropertyConstraint<? super V> constraint) Require that the given constraint be fulfilled on each item of the value of this property.Methods inherited from class net.sourceforge.pmd.properties.PropertyBuilder
availableInXPath, defaultValue, desc, getName
-
Method Details
-
require
public PropertyBuilder.GenericCollectionPropertyBuilder<V,C> require(PropertyConstraint<? super C> constraint) Description copied from class:PropertyBuilderAdd a constraint on the values that this property may take. The validity of values will be checked when parsing the XML, and invalid values will be reported. A rule will never be run if some of its properties violate some constraints.Constraints should be independent from each other, and should perform no side effects. PMD doesn't specify how many times a constraint predicate will be executed, or in what order.
- Specified by:
requirein classPropertyBuilder<PropertyBuilder.GenericCollectionPropertyBuilder<V,C extends Iterable<V>>, C extends Iterable<V>> - Parameters:
constraint- The constraint- Returns:
- The same builder
- See Also:
-
defaultValue
public PropertyBuilder.GenericCollectionPropertyBuilder<V,C> defaultValue(Iterable<? extends V> val) Specify a default value. This will be converted to type<C>with the supplied collector.- Parameters:
val- List of values- Returns:
- The same builder
-
defaultValues
Specify default values. To specify an empty default value, useemptyDefaultValue().- Parameters:
head- First valuetail- Rest of the values- Returns:
- The same builder
-
emptyDefaultValue
Specify that the default value is an empty collection.- Returns:
- The same builder
-
requireEach
public PropertyBuilder.GenericCollectionPropertyBuilder<V,C> requireEach(PropertyConstraint<? super V> constraint) Require that the given constraint be fulfilled on each item of the value of this property. This is a convenient shorthand forrequire(constraint.toCollectionConstraint()).- Parameters:
constraint- Constraint to impose on the items of the collection value- Returns:
- The same builder
-
build
Description copied from class:PropertyBuilderBuilds the descriptor and returns it.- Specified by:
buildin classPropertyBuilder<PropertyBuilder.GenericCollectionPropertyBuilder<V,C extends Iterable<V>>, C extends Iterable<V>> - Returns:
- The built descriptor
-