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 requireSQLsyntax, human user expectGLOBsyntax in search forms. Therefore this enum also supportsconversionfrom one syntax to another.- Since:
- 3.0.0
-
-
Constructor Summary
Constructors Modifier Constructor Description privateLikePatternSyntax(char any, char single)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static LikePatternSyntaxautoDetect(String pattern)Stringconvert(String pattern, LikePatternSyntax syntax)Stringconvert(String pattern, LikePatternSyntax syntax, boolean matchSubstring)chargetAny()chargetSingle()static LikePatternSyntaxvalueOf(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 wildcardand question-mark ('?') forsingle wildcard.
-
SQL
public static final LikePatternSyntax SQL
SQL syntax that is typically required by databases. It uses percent ('%') forany wildcardand underscore ('_') forsingle wildcard.
-
-
Field Detail
-
ESCAPE
public static final char ESCAPE
The escape character.- See Also:
- Constant Field Values
-
any
private final char any
-
single
private final char single
-
-
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
emptystring.
-
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- theLikePatternSyntaxof the givenpattern.- Returns:
- the given
patternconverted to thisLikePatternSyntax.
-
convert
public String convert(String pattern, LikePatternSyntax syntax, boolean matchSubstring)
- Parameters:
pattern- the LIKE pattern in the givenLikePatternSyntax.syntax- theLikePatternSyntaxof the givenpattern.matchSubstring- -trueif the givenpatternshall also match substrings,falseotherwise.- Returns:
- the given
patternconverted to thisLikePatternSyntax.
-
autoDetect
public static LikePatternSyntax autoDetect(String pattern)
- Parameters:
pattern- the string value that may be a pattern.- Returns:
- the
LikePatternSyntaxfor the givenpatternornullif the givenpatterndoes not contain any wildcards.
-
-