org.springframework.data.relational.core.dialect

## Class Escaper

- 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 `String`s.

Since:
  2.0
Author:
  Roman Chigvintsev, Mark Paluch

### Field Summary

Fields
`static Escaper` `DEFAULT`

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods
`String` `escape(String value)` Escapes all special like characters (`_`, `%`) using the configured escape character.
`char` `getEscapeCharacter()` Returns the escape character.
`static Escaper` `of(char escapeCharacter)` Creates new instance of this class with the given escape character.
`Escaper` `withRewriteFor(String... chars)` Apply the `Escaper` to the given `chars`.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### DEFAULT

    public static final Escaper DEFAULT

### Method Detail

#### 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