日常开发中有些符号常量,避免硬编码,需要提取工具类。
public class SymbolConstant {
public static final String SLASH = "/";
public static final String COMMA = ",";
public static final String MIDDLE_LINK = "-";
public static final String UNDER_LINE = "_";
public static final String HASH = "#";
public static final String MAIL_SPLITTER ="@";
public static final String TABLE_SPLITTER = "\t";
public static final String LEFT_CURLY_BRACKET = "{";
public static final String RIGHT_CURLY_BRACKET = "}";
public static final String COLON = ":";
public static final String LINEBREAK = "\n";
public static final String BLANK = "";
public static final String SPACE = " ";
public static final String QUESTION = "?";
public static final String ZERO = "0";
public static final String DOT = ".";
public static final String TOKEN = "token";
public static final String GET = "get";
public static final String CHARACTER_UTF_8 = "UTF-8";
public static final String CHARACTER_GBK = "GBK";
public static final String SET = "set";
public static final String HTTP = "http";
public static final String GRPC = "grpc";
public static final String BRACKETS = "{}";
public static final String BACKSLASH = "\\";
public static final String BACKSLASH_MARK= "\\\"";
public static final String DOUBLE_MARK= "\"\"";
public static final String MARK= "\"";
public static final String FLAG_EQUAL = "=";
public static final String LEFT_PARENTHESIS = "[";
public static final String RIGHT_PARENTHESIS = "]";
public static final String APOSTROPHE = "'";
public static final String QUESTION_MARK = "\\?";
public static final String HYPHEN = "-";
public static final String EVENT_SEPARATOR = "&&";
public static final String POST = "POST";
public static final String HTTP_SLASH = "http://";
public static final String PORT = "port";
public static final String LOCAL_HOST = "localhost";
public static final String POD_URL = "http://{}:{}?{}";
public static final String CPU_UNIT = "m";
public static final String MEM_UNIT = "Mi";
public static final String MEM_UNIT_GI = "Gi";
public static final String MEM_UNIT_KI = "Ki";
public static final String MEM_UNIT_TI = "Ti";
private SymbolConstant() {
}
}
正则表达式也是高配使用的,也需提取常量类
public final class RegularConstant {
/**
* 字母、数字、英文横杠和下划线匹配
*/
public static final String REGEXP_NAME = "^[a-zA-Z0-9\\-\\_\\u4e00-\\u9fa5]+$";
/**
* 字母、数字、英文横杠、英文.号和下划线
*/
public static final String REGEXP_TAG = "^[a-zA-Z0-9\\-\\_\\.]+$";
/**
* 算法名称支持字母、数字、汉字、英文横杠和下划线
*/
public static final String REGEXP_ALGORITHM = "^[a-zA-Z0-9\\-\\_\\u4e00-\\u9fa5]+$";
/**
* 资源规格名称支持字母、数字、汉字、英文横杠、下划线和空白字符
*/
public static final String REGEXP_SPECS = "^[a-zA-Z0-9\\-\\_\\s\\u4e00-\\u9fa5]+$";
/**
* 整数匹配
*/
public static final Pattern PATTERN_NUM = Pattern.compile("^[-\\+]?[\\d]*$");
/**
* 数字匹配
*/
public static final String NUMBER ="(\\d+)";
/**
* 整数匹配
*/
public static final Pattern PATTERN_NUMBER = Pattern.compile("(\\d+)");
/**
* 小数匹配
*/
public static final Pattern PATTERN_DECIMAL = Pattern.compile("(\\d+\\.\\d+)");
public static final String PATTERN_FILE_PATH="///*";
private RegularConstant(){}
}