Class StringUtils

java.lang.Object
org.flag4j.util.StringUtils

public final class StringUtils extends Object
A class which provides simple utility methods for strings.
  • Method Details

    • center

      public static String center(String s, int size)
      Centers a string within a specified size bin.
      Parameters:
      s - String to center.
      size - Size of the bin to center string within.
      Returns:
      A whitespace string of specified size with the string s centered within it.
    • center

      public static String center(String s, int size, String pad)
      Centers a string within a specified size bin.
      Parameters:
      s - String to center.
      size - Size of the bin to center string within.
      pad - Padding character.
      Returns:
      A string made up of the padding character of specified size with the string s centered within it.
    • ValueOfRound

      public static String ValueOfRound(double value, int precision)
      Gets the string representation of a double rounded to the specified precision.
      Parameters:
      value - Value to convert to String.
      precision - Precision to round value to.
      Returns:
      The string representation of a double rounded to the specified precision.
    • ValueOfRound

      public static <T> String ValueOfRound(T value, int precision)
      Gets the string representation of a field element rounded to the specified precision if possible.
      Parameters:
      value - Value to convert to String.
      precision - Precision to round value to if the value can be rounded.
      Returns:
      The string representation of value rounded to the specified precision if the field type can be rounded.