Class StringUtil


  • public final class StringUtil
    extends java.lang.Object
    Utility class for working with Strings.
    Since:
    2.0
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static interface  StringUtil.PropertySource
      A source of property values.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected static boolean LAZY_IF_EMPTY  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String doPropertySubstitution​(java.lang.String text, java.util.Properties properties)
      Substitutes ${key,default} place holders with their property values.
      static java.lang.String doPropertySubstitution​(java.lang.String text, StringUtil.PropertySource properties)
      Substitutes ${key,default} place holders with their property values.
      static boolean hasValue​(java.lang.Object obj)
      Returns whether the given object has a value.
      • Methods inherited from class java.lang.Object

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

      • LAZY_IF_EMPTY

        protected static final boolean LAZY_IF_EMPTY
    • Method Detail

      • hasValue

        public static boolean hasValue​(java.lang.Object obj)
        Returns whether the given object has a value.
        Parameters:
        obj - the object to test
        Returns:
        true if the object is not null (and not the empty string based on configuration)
      • doPropertySubstitution

        public static java.lang.String doPropertySubstitution​(java.lang.String text,
                                                              java.util.Properties properties)
                                                       throws java.lang.IllegalArgumentException
        Substitutes ${key,default} place holders with their property values.
        Parameters:
        text - the template text
        properties - the user provided property values
        Returns:
        the text after property substitution
        Throws:
        java.lang.IllegalArgumentException - if a property value does not exist
      • doPropertySubstitution

        public static java.lang.String doPropertySubstitution​(java.lang.String text,
                                                              StringUtil.PropertySource properties)
                                                       throws java.lang.IllegalArgumentException
        Substitutes ${key,default} place holders with their property values.
        Parameters:
        text - the template text
        properties - the user provided property values
        Returns:
        the text after property substitution
        Throws:
        java.lang.IllegalArgumentException - if a property value does not exist