java.lang.Object
com.streamconverter.command.rule.impl.string.TrimRule
All Implemented Interfaces:
IRule

public class TrimRule extends Object implements IRule
Trims leading and trailing whitespace from strings.

This rule removes whitespace characters from the beginning and end of the input string. Whitespace includes spaces, tabs, newlines, and other Unicode whitespace characters.

Examples:

  • " hello ""hello"
  • "\t\nworld\r\n""world"
  • "already trimmed""already trimmed"

Usage:


 IRule rule = new TrimRule();
 IStreamCommand command = JsonNavigateCommand.create("$.name", rule);
 
Since:
1.0
  • Constructor Details

  • Method Details

    • apply

      public String apply(String input)
      Description copied from interface: IRule
      ルールの適用を実行します。

      このメソッドは、ストリーム変換の際にルールを適用するために使用されます。 具体的なルールの実装は、このメソッドをオーバーライドして定義します。 変換対象とする箇所を特定したあとにこのメソッドを呼び出すことを想定しています。

      Specified by:
      apply in interface IRule
      Parameters:
      input - 変換対象の文字列
      Returns:
      String output 変換結果を格納する文字列
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object