Class IpsStringUtils

java.lang.Object
org.faktorips.runtime.internal.IpsStringUtils

public final class IpsStringUtils extends Object
A collection of utility methods for Strings. We don't use a class library like apache-commons here to minimize the dependencies for the generated code.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
    Compares two strings, treating null as EMPTY.
    static boolean
    Returns true if s is either null, the empty string or a string that only contains whitespace, otherwise false.
    static boolean
    Returns true if s is either null or the empty string, otherwise false.
    static boolean
    Returns true if s is neither null, the empty string nor a string that only contains whitespace, otherwise false.
    static boolean
    Returns true if s is neither null nor the empty string, otherwise false.
    static String
    join(Iterable<?> iterable)
    Joins the elements of the provided Iterable into a single String containing the provided elements with the default separator ", ".
    static String
    join(Iterable<?> iterable, String separator)
    Joins the elements of the provided Iterable into a single String containing the provided elements with the given separator.
    static <T> String
    join(Iterable<T> iterable, Function<? super T,String> toString)
    Joins the elements of the provided Iterable into a single String containing the provided elements, converted to String with the given toString Function, with the default separator ", ".
    static <T> String
    join(Iterable<T> iterable, Function<? super T,String> toString, String separator)
    Joins the elements of the provided Iterable into a single String containing the provided elements, converted to String with the given toString Function, with the given separator.
    static String
    join(Object[] objectArray)
    Joins the elements of the provided array into a single String containing the provided elements with the default separator ", ".
    static String
    join(Object[] objectArray, String separator)
    Joins the elements of the provided array into a single String containing the provided elements with the given separator.
    static String
    join(Collection<?> collection, String separator)
    Joins the elements of the provided Collection into a single String containing the provided elements with the given separator.
    static String
     
    static boolean
    Trims the parameters, if the are not null and checks for equality using Objects.equals(Object, Object).

    Methods inherited from class java.lang.Object

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

  • Method Details

    • isEmpty

      public static boolean isEmpty(String s)
      Returns true if s is either null or the empty string, otherwise false.
    • isNotEmpty

      public static boolean isNotEmpty(String s)
      Returns true if s is neither null nor the empty string, otherwise false.
    • isBlank

      public static boolean isBlank(String s)
      Returns true if s is either null, the empty string or a string that only contains whitespace, otherwise false.
    • isNotBlank

      public static boolean isNotBlank(String s)
      Returns true if s is neither null, the empty string nor a string that only contains whitespace, otherwise false.
    • trimEquals

      public static boolean trimEquals(String s1, String s2)
      Trims the parameters, if the are not null and checks for equality using Objects.equals(Object, Object).
      Parameters:
      s1 - a string
      s2 - another string to be compared with a for equality
      Returns:
      true if the arguments are equal to each other and false otherwise
    • equalsNullAsEmpty

      public static boolean equalsNullAsEmpty(String s1, String s2)
      Compares two strings, treating null as EMPTY.
      Parameters:
      s1 - a string
      s2 - another string
      Returns:
      whether both strings are equal
    • join

      public static String join(Collection<?> collection, String separator)
      Joins the elements of the provided Collection into a single String containing the provided elements with the given separator. No delimiter is added before or after the list.
      Parameters:
      collection - the Collection of values to join together, may be null
      separator - the separator to use, null treated as ""
      Returns:
      the joined String, empty if the collection is null
    • join

      public static String join(Iterable<?> iterable, String separator)
      Joins the elements of the provided Iterable into a single String containing the provided elements with the given separator. No delimiter is added before or after the list.
      Parameters:
      iterable - the Collection of values to join together, may be null
      separator - the separator to use, null treated as ""
      Returns:
      the joined String, empty if the collection is null
    • join

      public static String join(Iterable<?> iterable)
      Joins the elements of the provided Iterable into a single String containing the provided elements with the default separator ", ". No delimiter is added before or after the list.
      Parameters:
      iterable - the Collection of values to join together, may be null
      Returns:
      the joined String, empty if the collection is null
    • join

      public static String join(Object[] objectArray)
      Joins the elements of the provided array into a single String containing the provided elements with the default separator ", ". No delimiter is added before or after the list.
      Parameters:
      objectArray - the array of values to join together, may be null
      Returns:
      the joined String, empty if the collection is null
    • join

      public static String join(Object[] objectArray, String separator)
      Joins the elements of the provided array into a single String containing the provided elements with the given separator. No delimiter is added before or after the list.
      Parameters:
      objectArray - the array of values to join together, may be null
      separator - the separator to use, null treated as ""
      Returns:
      the joined String, empty if the collection is null
    • join

      public static <T> String join(Iterable<T> iterable, Function<? super T,String> toString)
      Joins the elements of the provided Iterable into a single String containing the provided elements, converted to String with the given toString Function, with the default separator ", ". No delimiter is added before or after the list.
      Parameters:
      iterable - the Collection of values to join together, may be null
      toString - the Function to convert an element from the Iterable to a String
      Returns:
      the joined String, null if the collection is null
    • join

      public static <T> String join(Iterable<T> iterable, Function<? super T,String> toString, String separator)
      Joins the elements of the provided Iterable into a single String containing the provided elements, converted to String with the given toString Function, with the given separator. No delimiter is added before or after the list.
      Parameters:
      iterable - the Collection of values to join together, may be null
      separator - the separator to use, null treated as ""
      toString - the Function to convert an element from the Iterable to a String
      Returns:
      the joined String, null if the collection is null
    • toLowerFirstChar

      public static String toLowerFirstChar(String string)