public enum SearchType extends Enum<SearchType>
文件名:SearchType.java
用途:定义提词或断言的搜索范围枚举
编码时间:2022年5月5日 上午8:10:08
修改时间:2022年5月5日 上午8:10:08
Enum Constant and Description |
---|
BODY
搜索响应体信息
|
HEADER
搜索响应头信息
|
MESSAGE
搜索响应消息
|
STATUS
搜索响应状态码
|
Modifier and Type | Method and Description |
---|---|
static SearchType |
typeText2Type(String type)
该方法用于将枚举文本转换为消息枚举
|
static SearchType |
typeText2Type(String type,
Function<String,String> mapper)
该方法用于将枚举文本转换为消息枚举
|
static SearchType |
valueOf(String name)
Returns the enum constant of this type with the specified name.
|
static SearchType[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final SearchType HEADER
public static final SearchType BODY
public static final SearchType STATUS
public static final SearchType MESSAGE
public static SearchType[] values()
for (SearchType c : SearchType.values()) System.out.println(c);
public static SearchType valueOf(String name)
name
- the name of the enum constant to be returned.IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is nullpublic static SearchType typeText2Type(String type)
该方法本质上与valueOf(String)
方法的作用一致,但其中加上了对文本的内容的判空、对文本内容大写转换、
对特殊文本进行处理以及对异常文本进行汉化的操作。
type
- 枚举文本内容IllegalArgumentException
- 当枚举文本为空或不能转换成枚举时抛出的异常public static SearchType typeText2Type(String type, Function<String,String> mapper)
该方法与typeText2Type(String)
方法类似,其可对传入的文本进行自定义的转换,例如欲将传入的"bo"转换为"body",则可写为
SearchType.typeText2MessageType("bo", type -> {
if ("bo".equals(text)) {
text = "body";
}
return text;
});
type
- 枚举文本内容mapper
- 枚举文本的处理方法IllegalArgumentException
- 当枚举文本为空或不能转换成枚举时抛出的异常Copyright © 2024. All rights reserved.