java.lang.Object
org.springframework.data.relational.core.dialect.Escaper

public class Escaper extends Object
Helper class encapsulating an escape character for LIKE queries and the actually usage of it in escaping Strings.
Since:
2.0
Author:
Roman Chigvintsev, Mark Paluch
  • Field Details

    • DEFAULT

      public static final Escaper DEFAULT
  • Method Details

    • of

      public static Escaper of(char escapeCharacter)
      Creates new instance of this class with the given escape character.
      Parameters:
      escapeCharacter - escape character
      Returns:
      new instance of Escaper.
      Throws:
      IllegalArgumentException - if escape character is one of special characters ('_' and '%')
    • withRewriteFor

      public Escaper withRewriteFor(String... chars)
      Apply the Escaper to the given chars.
      Parameters:
      chars - characters/char sequences that should be escaped.
      Returns:
    • getEscapeCharacter

      public char getEscapeCharacter()
      Returns the escape character.
      Returns:
      the escape character to use.
    • escape

      @Nullable public String escape(@Nullable String value)
      Escapes all special like characters (_, %) using the configured escape character.
      Parameters:
      value - value to be escaped
      Returns:
      escaped value