Class 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.Pattern PROPERTY_VARIABLE_PATTERN
      Property variable expression pattern, matches property variables such as ${basedir}.
      static java.lang.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​(java.lang.String propertyValue)
      Checks if all chained properties have been resolved.
      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 '}'.
      static java.util.Properties getResolvedProperties​(java.util.Properties properties)
      Accepts user defined properties and returns new properties with all chained properties resolved.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • PROPERTY_VARIABLE_PATTERN

        private static final java.util.regex.Pattern PROPERTY_VARIABLE_PATTERN
        Property variable expression pattern, matches property variables such as ${basedir}.
    • 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