Class ChainedPropertyUtil
- java.lang.Object
-
- com.puppycrawl.tools.checkstyle.utils.ChainedPropertyUtil
-
public final class ChainedPropertyUtil extends Object
Resolves chained properties from a user-defined property file.
-
-
Field Summary
Fields Modifier and Type Field Description private static Pattern
PROPERTY_VARIABLE_PATTERN
Property variable expression pattern, matches property variables such as${basedir}
.static String
UNDEFINED_PROPERTY_MESSAGE
Used to report undefined property in exception message.
-
Constructor Summary
Constructors Modifier Constructor Description private
ChainedPropertyUtil()
Prevent instantiation.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static boolean
allChainedPropertiesAreResolved(String propertyValue)
Checks if all chained properties have been resolved.private static String
getPropertyNameFromExpression(String variableExpression)
Gets an unresolved property name from a property variable expression by stripping the preceding '${' and trailing '}'.static Properties
getResolvedProperties(Properties properties)
Accepts user defined properties and returns new properties with all chained properties resolved.
-
-
-
Field Detail
-
UNDEFINED_PROPERTY_MESSAGE
public static final String UNDEFINED_PROPERTY_MESSAGE
Used to report undefined property in exception message.- See Also:
- Constant Field Values
-
PROPERTY_VARIABLE_PATTERN
private static final 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 Properties getResolvedProperties(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 String getPropertyNameFromExpression(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(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
-
-