From a9efe39944018be655cc5b958a100298443c5952 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Fournier?= Date: Fri, 13 Sep 2019 01:14:35 +0200 Subject: [PATCH] Remove multi value properties --- .../MultiValuePropertyDescriptor.java | 39 ------------------- .../properties/NumericPropertyDescriptor.java | 34 ---------------- .../pmd/properties/PropertyBuilder.java | 4 +- .../pmd/properties/internal/SyntaxSet.java | 16 +++++++- .../pmd/docs/RuleDocGenerator.java | 34 ++++++++-------- 5 files changed, 32 insertions(+), 95 deletions(-) delete mode 100644 pmd-core/src/main/java/net/sourceforge/pmd/properties/MultiValuePropertyDescriptor.java delete mode 100644 pmd-core/src/main/java/net/sourceforge/pmd/properties/NumericPropertyDescriptor.java diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/properties/MultiValuePropertyDescriptor.java b/pmd-core/src/main/java/net/sourceforge/pmd/properties/MultiValuePropertyDescriptor.java deleted file mode 100644 index 4122ed8928..0000000000 --- a/pmd-core/src/main/java/net/sourceforge/pmd/properties/MultiValuePropertyDescriptor.java +++ /dev/null @@ -1,39 +0,0 @@ -/** - * BSD-style license; for more info see http://pmd.sourceforge.net/license.html - */ - -package net.sourceforge.pmd.properties; - -import java.util.List; - - -/** - * Specializes property descriptors for multi valued descriptors. - * @author Clément Fournier - * @since 6.0.0 - * - * @deprecated The hard divide between multi- and single-value properties will be removed with 7.0.0 - */ -@Deprecated -public interface MultiValuePropertyDescriptor extends PropertyDescriptor> { - - /** Default delimiter for multi-valued properties other than numeric ones. */ - @Deprecated - char DEFAULT_DELIMITER = '|'; - - /** Default delimiter for numeric multi-valued properties. */ - @Deprecated - char DEFAULT_NUMERIC_DELIMITER = ','; - - - /** - * Return the character being used to delimit multiple property values within a single string. You must ensure that - * this character does not appear within any rule property values to avoid deserialization errors. - * - * @return char - */ - @Deprecated - char multiValueDelimiter(); - - -} diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/properties/NumericPropertyDescriptor.java b/pmd-core/src/main/java/net/sourceforge/pmd/properties/NumericPropertyDescriptor.java deleted file mode 100644 index d8b75e4089..0000000000 --- a/pmd-core/src/main/java/net/sourceforge/pmd/properties/NumericPropertyDescriptor.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * BSD-style license; for more info see http://pmd.sourceforge.net/license.html - */ - -package net.sourceforge.pmd.properties; - -/** - * Defines a descriptor type whose instance values are required to lie within specified upper and lower limits. - * - * @param type of the property value - * - * @deprecated Will be removed with 7.0.0. In the future this interface won't exist, - * but numeric properties will still be around - * @author Brian Remedios - * @author Clément Fournier - */ -@Deprecated -public interface NumericPropertyDescriptor extends PropertyDescriptor { - - /** - * Returns the maximum value that instances of the property can have. - * - * @return Number - */ - Number upperLimit(); - - - /** - * Returns the minimum value that instances of the property can have. - * - * @return Number - */ - Number lowerLimit(); -} diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/properties/PropertyBuilder.java b/pmd-core/src/main/java/net/sourceforge/pmd/properties/PropertyBuilder.java index 03ea35355b..12d2785cbd 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/properties/PropertyBuilder.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/properties/PropertyBuilder.java @@ -433,8 +433,8 @@ public abstract class PropertyBuilder, T> { /** - * Specify a delimiter character. By default it's {@link MultiValuePropertyDescriptor#DEFAULT_DELIMITER}, or {@link - * MultiValuePropertyDescriptor#DEFAULT_NUMERIC_DELIMITER} for numeric properties. + * Specify a delimiter character. By default it's {@value PropertyFactory#DEFAULT_DELIMITER}, + * or {@value PropertyFactory#DEFAULT_NUMERIC_DELIMITER} for numeric properties. * * @param delim Delimiter * diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/properties/internal/SyntaxSet.java b/pmd-core/src/main/java/net/sourceforge/pmd/properties/internal/SyntaxSet.java index 619a821c6f..d353bcb032 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/properties/internal/SyntaxSet.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/properties/internal/SyntaxSet.java @@ -62,11 +62,23 @@ public final class SyntaxSet extends XmlSyntax { } @Override - public @Nullable T fromString(String attributeData) { + public @Nullable T fromString(String string) { for (XmlSyntax syntax : supportedReadStrategies()) { if (syntax.supportsStringMapping()) { - return syntax.fromString(attributeData); + return syntax.fromString(string); + } + } + + throw new UnsupportedOperationException(); + } + + @Override + public String toString(T value) { + + for (XmlSyntax syntax : supportedReadStrategies()) { + if (syntax.supportsStringMapping()) { + return syntax.toString(value); } } diff --git a/pmd-doc/src/main/java/net/sourceforge/pmd/docs/RuleDocGenerator.java b/pmd-doc/src/main/java/net/sourceforge/pmd/docs/RuleDocGenerator.java index fc2ce7b910..868428f5d2 100644 --- a/pmd-doc/src/main/java/net/sourceforge/pmd/docs/RuleDocGenerator.java +++ b/pmd-doc/src/main/java/net/sourceforge/pmd/docs/RuleDocGenerator.java @@ -28,7 +28,6 @@ import java.util.TreeMap; import java.util.logging.Level; import java.util.logging.Logger; import java.util.regex.Matcher; -import java.util.regex.Pattern; import org.apache.commons.io.FilenameUtils; import org.apache.commons.lang3.StringUtils; @@ -42,7 +41,6 @@ import net.sourceforge.pmd.RulesetsFactoryUtils; import net.sourceforge.pmd.lang.Language; import net.sourceforge.pmd.lang.rule.RuleReference; import net.sourceforge.pmd.lang.rule.XPathRule; -import net.sourceforge.pmd.properties.MultiValuePropertyDescriptor; import net.sourceforge.pmd.properties.PropertyDescriptor; public class RuleDocGenerator { @@ -460,12 +458,13 @@ public class RuleDocGenerator { String defaultValue = determineDefaultValueAsString(propertyDescriptor, rule, true); String multiValued = "no"; - if (propertyDescriptor.isMultiValue()) { - MultiValuePropertyDescriptor multiValuePropertyDescriptor = - (MultiValuePropertyDescriptor) propertyDescriptor; - multiValued = "yes. Delimiter is '" - + multiValuePropertyDescriptor.multiValueDelimiter() + "'."; - } + // TODO document property syntax + // if (propertyDescriptor.isMultiValue()) { + // MultiValuePropertyDescriptor multiValuePropertyDescriptor = + // (MultiValuePropertyDescriptor) propertyDescriptor; + // multiValued = "yes. Delimiter is '" + // + multiValuePropertyDescriptor.multiValueDelimiter() + "'."; + // } lines.add("|" + EscapeUtils.escapeMarkdown(StringEscapeUtils.escapeHtml4(propertyDescriptor.name())) + "|" + EscapeUtils.escapeMarkdown(StringEscapeUtils.escapeHtml4(defaultValue)) + "|" @@ -531,16 +530,15 @@ public class RuleDocGenerator { if (realDefaultValue != null) { defaultValue = propertyDescriptor.asDelimitedString(realDefaultValue); - - if (pad && propertyDescriptor.isMultiValue()) { - MultiValuePropertyDescriptor> multiPropertyDescriptor = (MultiValuePropertyDescriptor>) propertyDescriptor; - - // surround the delimiter with spaces, so that the browser can wrap - // the value nicely - defaultValue = defaultValue.replaceAll(Pattern.quote( - String.valueOf(multiPropertyDescriptor.multiValueDelimiter())), - " " + multiPropertyDescriptor.multiValueDelimiter() + " "); - } + // TODO document multi value properties + // if (pad && propertyDescriptor.isMultiValue()) { + // MultiValuePropertyDescriptor> multiPropertyDescriptor = (MultiValuePropertyDescriptor>) propertyDescriptor; + // // surround the delimiter with spaces, so that the browser can wrap + // // the value nicely + // defaultValue = defaultValue.replaceAll(Pattern.quote( + // String.valueOf(multiPropertyDescriptor.multiValueDelimiter())), + // " " + multiPropertyDescriptor.multiValueDelimiter() + " "); + // } } return defaultValue; }