Class ChainedPropertyUtil
- java.lang.Object
-
- com.puppycrawl.tools.checkstyle.utils.ChainedPropertyUtil
-
public final class ChainedPropertyUtil extends java.lang.Object
Resolves chained properties from a user-defined property file.
-
-
Field Summary
Fields Modifier and Type Field Description private static java.util.regex.PatternPROPERTY_VARIABLE_PATTERNProperty variable expression pattern, matches property variables such as${basedir}.static java.lang.StringUNDEFINED_PROPERTY_MESSAGEUsed to report undefined property in exception message.
-
Constructor Summary
Constructors Modifier Constructor Description privateChainedPropertyUtil()Prevent instantiation.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static booleanallChainedPropertiesAreResolved(java.lang.String propertyValue)Checks if all chained properties have been resolved.private static java.lang.StringgetPropertyNameFromExpression(java.lang.String variableExpression)Gets an unresolved property name from a property variable expression by stripping the preceding '${' and trailing '}'.static java.util.PropertiesgetResolvedProperties(java.util.Properties properties)Accepts user defined properties and returns new properties with all chained properties resolved.
-
-
-
Field Detail
-
UNDEFINED_PROPERTY_MESSAGE
public static final java.lang.String UNDEFINED_PROPERTY_MESSAGE
Used to report undefined property in exception message.- See Also:
- Constant Field Values
-
PROPERTY_VARIABLE_PATTERN
private static final java.util.regex.Pattern PROPERTY_VARIABLE_PATTERN
Property variable expression pattern, matches property variables such as${basedir}.
-
-
Constructor Detail
-
ChainedPropertyUtil
private ChainedPropertyUtil()
Prevent instantiation.
-
-
Method Detail
-
getResolvedProperties
public static java.util.Properties getResolvedProperties(java.util.Properties properties) throws CheckstyleException
Accepts user defined properties and returns new properties with all chained properties resolved.- Parameters:
properties- the underlying properties to use for property resolution.- Returns:
- resolved properties
- Throws:
CheckstyleException- when chained property is not defined
-
getPropertyNameFromExpression
private static java.lang.String getPropertyNameFromExpression(java.lang.String variableExpression)
Gets an unresolved property name from a property variable expression by stripping the preceding '${' and trailing '}'.- Parameters:
variableExpression- the full property variable expression- Returns:
- property name
-
allChainedPropertiesAreResolved
private static boolean allChainedPropertiesAreResolved(java.lang.String propertyValue)
Checks if all chained properties have been resolved. Essentially, this means that there exist no matches for PROPERTY_VARIABLE_PATTERN in the property value string.- Parameters:
propertyValue- the property value to check- Returns:
- true if all chained properties are resolved
-
-