Class CamelToSnakeCaseRule

java.lang.Object
com.streamconverter.command.rule.impl.casing.CamelToSnakeCaseRule
All Implemented Interfaces:
IRule

public class CamelToSnakeCaseRule extends Object implements IRule
Transforms camelCase strings to snake_case format.

This rule converts strings from camelCase notation to snake_case notation by inserting underscores before uppercase letters and converting all letters to lowercase.

Examples:

  • userNameuser_name
  • firstNamefirst_name
  • userAccountIDuser_account_id
  • XMLHttpRequestxml_http_request

Usage:


 IRule rule = CamelToSnakeCaseRule.builder().build();
 IStreamCommand command = JsonNavigateCommand.create("$.userName", rule);
 
Since:
1.0
  • Method Details

    • apply

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

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

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

      Creates a builder for configuring the CamelToSnakeCaseRule.
      Returns:
      new builder instance
    • create

      public static CamelToSnakeCaseRule create()
      Creates a CamelToSnakeCaseRule with default settings.
      Returns:
      new rule instance with default configuration
    • toString

      public String toString()
      Overrides:
      toString in class Object