Class StringHelper

java.lang.Object
org.hibernate.validator.internal.util.StringHelper

public class StringHelper extends Object
Helper class dealing with strings.
Author:
Gunnar Morling
  • Method Summary

    Modifier and Type
    Method
    Description
    static String
    Returns the given string, with its first letter changed to lower-case unless the string starts with more than one upper-case letter, in which case the string will be returned unaltered.
    static String
    format(String format, Object... args)
     
    static boolean
    Indicates if the string is null or is empty ie only contains whitespaces.
    static String
    join(Iterable<?> iterable, String separator)
    Joins the elements of the given iterable to a string, separated by the given separator string.
    static String
    join(Object[] array, String separator)
    Joins the elements of the given array to a string, separated by the given separator string.
    static String
    Creates a compact string representation of the given member, useful for debugging or toString() methods.
    static String
    Creates a compact string representation of the given type, useful for debugging or toString() methods.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • join

      public static String join(Object[] array, String separator)
      Joins the elements of the given array to a string, separated by the given separator string.
      Parameters:
      array - the array to join
      separator - the separator string
      Returns:
      a string made up of the string representations of the given array's members, separated by the given separator string
    • join

      public static String join(Iterable<?> iterable, String separator)
      Joins the elements of the given iterable to a string, separated by the given separator string.
      Parameters:
      iterable - the iterable to join
      separator - the separator string
      Returns:
      a string made up of the string representations of the given iterable members, separated by the given separator string
    • decapitalize

      public static String decapitalize(String string)
      Returns the given string, with its first letter changed to lower-case unless the string starts with more than one upper-case letter, in which case the string will be returned unaltered.

      Provided to avoid a dependency on the Introspector API which is not available on the Android platform (HV-779).

      Parameters:
      string - the string to decapitalize
      Returns:
      the given string, decapitalized. null is returned if null is passed as input; An empty string is returned if an empty string is passed as input
      See Also:
    • isNullOrEmptyString

      public static boolean isNullOrEmptyString(String value)
      Indicates if the string is null or is empty ie only contains whitespaces.
      Parameters:
      value - the string considered
      Returns:
      true if the string is null or only contains whitespaces
    • toShortString

      public static String toShortString(Member member)
      Creates a compact string representation of the given member, useful for debugging or toString() methods. Package names are shortened, e.g. "org.hibernate.validator.internal.engine" becomes "o.h.v.i.e". Not to be used for user-visible log messages.
    • toShortString

      public static String toShortString(Type type)
      Creates a compact string representation of the given type, useful for debugging or toString() methods. Package names are shortened, e.g. "org.hibernate.validator.internal.engine" becomes "o.h.v.i.e". Not to be used for user-visible log messages.
    • format

      public static String format(String format, Object... args)