Enum LikePatternSyntax
- java.lang.Object
-
- java.lang.Enum<LikePatternSyntax>
-
- com.devonfw.module.basic.common.api.query.LikePatternSyntax
-
- All Implemented Interfaces:
Serializable
,Comparable<LikePatternSyntax>
public enum LikePatternSyntax extends Enum<LikePatternSyntax>
Enum defining available syntaxes for a match pattern in a LIKE-clause. While databases typically requireSQL
syntax, human user expectGLOB
syntax in search forms. Therefore this enum also supportsconversion
from one syntax to another.- Since:
- 3.0.0
-
-
Field Summary
Fields Modifier and Type Field Description static char
ESCAPE
The escape character.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static LikePatternSyntax
autoDetect(String pattern)
String
convert(String pattern, LikePatternSyntax syntax)
String
convert(String pattern, LikePatternSyntax syntax, boolean matchSubstring)
char
getAny()
char
getSingle()
static LikePatternSyntax
valueOf(String name)
Returns the enum constant of this type with the specified name.static LikePatternSyntax[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
GLOB
public static final LikePatternSyntax GLOB
Glob syntax that is typically expected by end-users and supported by typical search forms. It uses asterisk ('*') forany wildcard
and question-mark ('?') forsingle wildcard
.
-
SQL
public static final LikePatternSyntax SQL
SQL syntax that is typically required by databases. It uses percent ('%') forany wildcard
and underscore ('_') forsingle wildcard
.
-
-
Field Detail
-
ESCAPE
public static final char ESCAPE
The escape character.- See Also:
- Constant Field Values
-
-
Method Detail
-
values
public static LikePatternSyntax[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (LikePatternSyntax c : LikePatternSyntax.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static LikePatternSyntax valueOf(String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (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 type has no constant with the specified nameNullPointerException
- if the argument is null
-
getAny
public char getAny()
- Returns:
- the wildcard character that matches any string including the
empty
string.
-
getSingle
public char getSingle()
- Returns:
- the wildcard character that matches exactly one single character.
-
convert
public String convert(String pattern, LikePatternSyntax syntax)
- Parameters:
pattern
- the LIKE pattern in the givenLikePatternSyntax
.syntax
- theLikePatternSyntax
of the givenpattern
.- Returns:
- the given
pattern
converted to thisLikePatternSyntax
.
-
convert
public String convert(String pattern, LikePatternSyntax syntax, boolean matchSubstring)
- Parameters:
pattern
- the LIKE pattern in the givenLikePatternSyntax
.syntax
- theLikePatternSyntax
of the givenpattern
.matchSubstring
- -true
if the givenpattern
shall also match substrings,false
otherwise.- Returns:
- the given
pattern
converted to thisLikePatternSyntax
.
-
autoDetect
public static LikePatternSyntax autoDetect(String pattern)
- Parameters:
pattern
- the string value that may be a pattern.- Returns:
- the
LikePatternSyntax
for the givenpattern
ornull
if the givenpattern
does not contain any wildcards.
-
-