Package net.sourceforge.pmd.properties
Class PropertySerializer<T>
java.lang.Object
net.sourceforge.pmd.properties.PropertySerializer<T>
- Direct Known Subclasses:
InternalApiBridge.InternalPropertySerializer
Strategy to serialize a value to and from strings.
-
Method Summary
Modifier and TypeMethodDescriptionabstract Set<?> If this property only allows specific enumerated values, this set contains all possible values.abstract TfromString(@NonNull String attributeData) Read the value from a string, if it is supported.abstract List<PropertyConstraint<? super T>> Returns the constraints that this mapper applies to values after parsing them.abstract booleanWhether this property allows multiple values.abstract booleanisFromStringDeprecated(@NonNull String attributeData) For properties that are based off enumerated values (seeenumeratedValues(), deprecated values might be provided.abstract @NonNull StringFormat the value to a string.withConstraint(PropertyConstraint<? super T> t) Returns a new XML mapper that will check parsed values with the given constraint.
-
Method Details
-
getConstraints
Returns the constraints that this mapper applies to values after parsing them. This may be used for documentation, or to check a constraint on a value that was not parsed from XML.- Implementation Note:
- See
ConstraintDecorator
-
withConstraint
Returns a new XML mapper that will check parsed values with the given constraint. -
fromString
Read the value from a string, if it is supported.- Throws:
IllegalArgumentException- if something goes wrong (but should be reported on the error reporter)
-
isFromStringDeprecated
For properties that are based off enumerated values (seeenumeratedValues(), deprecated values might be provided. This method checks whether the given attribute data is actually a deprecated value so that we can issue a warning.- Since:
- 7.21.0
-
toString
Format the value to a string.- Throws:
IllegalArgumentException- if something goes wrong (but should be reported on the error reporter)
-
isCollection
public abstract boolean isCollection()Whether this property allows multiple values.- Since:
- 7.21.0
-
enumeratedValues
If this property only allows specific enumerated values, this set contains all possible values. This is useful for documentation. If this property doesn't represent an enumerated property, then the returned set will be empty.- Since:
- 7.21.0
-