Class PropertyBuilder.RegexPropertyBuilder

    • Method Detail

      • require

        public B require​(PropertyConstraint<? super T> 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 class PropertyBuilder<B extends PropertyBuilder<B,​T>,​T>
        Parameters:
        constraint - The constraint
        Returns:
        The same builder
        See Also:
        NumericConstraints
      • toList

        public PropertyBuilder.GenericCollectionPropertyBuilder<T,​List<T>> 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(Collector)
      • 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

        public PropertyBuilder.GenericPropertyBuilder<Optional<T>> toOptional​(String missingValue)
        Returns a new builder that can be used to build a property handling Optional<T>. The validators already added are used on the validator property. If the default value was previously set, it is converted to an optional with Optional.of(Object).
        Parameters:
        missingValue - The string representation of the empty optional.
        Returns:
        A new property builder for an optional.