Package net.sourceforge.pmd.properties
Class PropertyBuilder<B extends PropertyBuilder<B,T>,T>
- java.lang.Object
- 
- net.sourceforge.pmd.properties.PropertyBuilder<B,T>
 
- 
- Type Parameters:
- B- Concrete type of this builder instance
- T- Type of values the property handles
 - Direct Known Subclasses:
- PropertyBuilder.GenericCollectionPropertyBuilder,- PropertyBuilder.GenericPropertyBuilder,- PropertyBuilder.RegexPropertyBuilder
 
 public abstract class PropertyBuilder<B extends PropertyBuilder<B,T>,T> extends java.lang.ObjectBase class for generic property builders. Property builders are obtained from thePropertyFactory, and are used to buildPropertyDescriptors.All properties must specify the following attributes to build properly: - A name: filled-in when obtaining the builder
- A description: see desc(String)
- A default value: see defaultValue(Object)
 The PropertyDescriptormay be built after those required steps by callingbuild().A property builder may throw IllegalArgumentExceptionat any stage during the build process to indicate invalid input. It usually tries to do so as early as possible, rather than waiting for the call tobuild().Note: from 7.0.0 on, all property builders will extend this class instead of PropertyDescriptorBuilder.- Since:
- 6.10.0
- Author:
- Clément Fournier
 
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description static classPropertyBuilder.GenericCollectionPropertyBuilder<V,C extends java.util.Collection<V>>Generic builder for a collection-valued property.static classPropertyBuilder.GenericPropertyBuilder<T>Generic builder for a single-value property.static classPropertyBuilder.RegexPropertyBuilderSpecialized builder for regex properties.
 - 
Field SummaryFields Modifier and Type Field Description protected booleanisDefinedExternally
 - 
Method SummaryAll Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract PropertyDescriptor<T>build()Builds the descriptor and returns it.BdefaultValue(T val)Specify a default value.Bdesc(java.lang.String desc)Specify the description of the property.java.lang.StringgetName()Returns the name of the property to be built.Brequire(PropertyConstraint<? super T> constraint)Add a constraint on the values that this property may take.
 
- 
- 
- 
Method Detail- 
descpublic B desc(java.lang.String desc) Specify the description of the property. This is used for documentation. Please describe precisely how the property may change the behaviour of the rule. Providing complete information should be preferred over being concise.Calling this method is required for build()to succeed.- Parameters:
- desc- The description
- Returns:
- The same builder
- Throws:
- java.lang.IllegalArgumentException- If the description is null or whitespace
 
 - 
requirepublic B require(PropertyConstraint<? super T> constraint) 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.- Parameters:
- constraint- The constraint
- Returns:
- The same builder
- See Also:
- NumericConstraints
 
 - 
defaultValuepublic B defaultValue(T val) Specify a default value. Some subclasses provide convenient related methods, see e.g.PropertyBuilder.GenericCollectionPropertyBuilder.defaultValues(Object, Object[]). Using the null value is prohibited.Calling this method is required for build()to succeed.- Parameters:
- val- Default value
- Returns:
- The same builder
- Throws:
- java.lang.IllegalArgumentException- If the argument is null
 
 - 
buildpublic abstract PropertyDescriptor<T> build() Builds the descriptor and returns it.- Returns:
- The built descriptor
- Throws:
- java.lang.IllegalArgumentException- if the description or default value were not provided, or if the default value doesn't satisfy the given constraints
 
 - 
getNamepublic java.lang.String getName() Returns the name of the property to be built.
 
- 
 
-