Package net.sourceforge.pmd.properties
Class PropertyBuilder.GenericPropertyBuilder<T>
java.lang.Object
net.sourceforge.pmd.properties.PropertyBuilder<B,T>
net.sourceforge.pmd.properties.PropertyBuilder.GenericPropertyBuilder<T>
- Type Parameters:
T- Type of values the property handles
- Enclosing class:
- PropertyBuilder<B extends PropertyBuilder<B,
T>, T>
Generic builder for a single-value property.
- 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.protected PropertySerializer<T><C extends Iterable<T>>
PropertyBuilder.GenericCollectionPropertyBuilder<T,C> Returns a new builder that can be used to build a property with value type<C>.require(PropertyConstraint<? super T> constraint) Add a constraint on the values that this property may take.toList()Returns a new builder that can be used to build a property handling lists of Ts.toOptional(String missingValue) Returns a new builder that can be used to build a property handlingOptional<T>.Methods inherited from class net.sourceforge.pmd.properties.PropertyBuilder
availableInXPath, defaultValue, desc, getName
-
Method Details
-
getParser
-
require
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<B extends PropertyBuilder<B,T>, T> - Parameters:
constraint- The constraint- Returns:
- The same builder
- See Also:
-
toList
Returns a new builder that can be used to build a property handling lists of Ts. The validators already added are converted to list validators. The default value cannot have previously been set.- Returns:
- A new list property builder
- Throws:
IllegalStateException- if the default value has already been set- See Also:
-
map
public <C extends Iterable<T>> PropertyBuilder.GenericCollectionPropertyBuilder<T,C> map(Collector<? super T, ?, ? extends C> collector) Returns a new builder that can be used to build a property with value type<C>. The validators already added are converted to collection validators. The default value cannot have previously been set. The returned builder will support conversion to and from a delimited string.Example usage:
// this can be set with // <value>a,b,c</value> PropertyDescriptor<Set<String>> whitelistSet = PropertyFactory.stringProperty("whitelist") .desc(...) .map(Collectors.toSet()) .emptyDefaultValue() .build();- Returns:
- A new list property builder
- Throws:
IllegalStateException- if the default value has already been set
-
toOptional
Returns a new builder that can be used to build a property handlingOptional<T>. The validators already added are used on the validator property. If the default value was previously set, it is converted to an optional withOptional.of(Object).- Parameters:
missingValue- The string representation of the empty optional.- Returns:
- A new property builder for an optional.
-
build
Description copied from class:PropertyBuilderBuilds the descriptor and returns it.- Specified by:
buildin classPropertyBuilder<B extends PropertyBuilder<B,T>, T> - Returns:
- The built descriptor
-