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 todefaultValue(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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description PropertyDescriptor<C>
build()
Builds the descriptor and returns it.PropertyBuilder.GenericCollectionPropertyBuilder<V,C>
defaultValue(Iterable<? extends V> val)
Specify a default value.PropertyBuilder.GenericCollectionPropertyBuilder<V,C>
defaultValues(V head, V... tail)
Specify default values.PropertyBuilder.GenericCollectionPropertyBuilder<V,C>
emptyDefaultValue()
Specify that the default value is an empty collection.PropertyBuilder.GenericCollectionPropertyBuilder<V,C>
require(PropertyConstraint<? super C> constraint)
Add a constraint on the values that this property may take.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.-
Methods inherited from class net.sourceforge.pmd.properties.PropertyBuilder
availableInXPath, defaultValue, desc, getName
-
-
-
-
Method Detail
-
require
public PropertyBuilder.GenericCollectionPropertyBuilder<V,C> require(PropertyConstraint<? super C> constraint)
Description copied from class:PropertyBuilder
Add 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:
require
in classPropertyBuilder<PropertyBuilder.GenericCollectionPropertyBuilder<V,C extends Iterable<V>>,C extends Iterable<V>>
- Parameters:
constraint
- The constraint- Returns:
- The same builder
- See Also:
NumericConstraints
-
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
public PropertyBuilder.GenericCollectionPropertyBuilder<V,C> defaultValues(V head, V... tail)
Specify default values. To specify an empty default value, useemptyDefaultValue()
.- Parameters:
head
- First valuetail
- Rest of the values- Returns:
- The same builder
-
emptyDefaultValue
public PropertyBuilder.GenericCollectionPropertyBuilder<V,C> 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
public PropertyDescriptor<C> build()
Description copied from class:PropertyBuilder
Builds the descriptor and returns it.- Specified by:
build
in classPropertyBuilder<PropertyBuilder.GenericCollectionPropertyBuilder<V,C extends Iterable<V>>,C extends Iterable<V>>
- Returns:
- The built descriptor
-
-