Enum Class StripMode

java.lang.Object
java.lang.Enum<StripMode>
org.tentackle.common.StripMode
All Implemented Interfaces:
Serializable, Comparable<StripMode>, Constable

public enum StripMode extends Enum<StripMode>
Stripping mode for strings with respect to a filler character.
  • Enum Constant Details

    • NONE

      public static final StripMode NONE
      No stripping.
    • LEFT

      public static final StripMode LEFT
      Remove leading filler characters.
    • BOTH

      public static final StripMode BOTH
      Remove leading and trailing filler characters.
      This is the default.
  • Method Details

    • values

      public static StripMode[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static StripMode valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • isStripLeft

      public boolean isStripLeft()
      Returns true if the mode strips the left side.
      Returns:
      true if the mode strips the left side
    • isStripRight

      public boolean isStripRight()
      Returns true if the mode strips the right side.
      Returns:
      true if the mode strips the right side
    • getBindOption

      public String getBindOption()
      Gets the bind option name.
      Returns:
      the bind option name
    • strip

      public String strip(String text, char filler)
      Strips the given text.
      Parameters:
      text - the original text, null if none
      filler - the filler character
      Returns:
      the stripped text, null if none
    • fromBindOption

      public static StripMode fromBindOption(String s)
      Converts a mode string as defined in Constants to a StripMode.

      Throws a TentackleRuntimeException if the string is invalid.

      Parameters:
      s - one of Constants.BIND_STRIP_NONE, Constants.BIND_STRIP_LEFT, Constants.BIND_STRIP_RIGHT, Constants.BIND_STRIP_BOTH, case-insensitive
      Returns:
      the corresponding StripMode