com.viiyue.plugins.mybatis.Constants Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mybatis-mapper Show documentation
Show all versions of mybatis-mapper Show documentation
Mybatis generic mapper plugin for solving most basic operations,
simplifying sql syntax and improving dynamic execution efficiency
/**
* Copyright (C) 2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.viiyue.plugins.mybatis;
import java.util.Arrays;
import java.util.List;
import java.util.regex.Pattern;
import com.viiyue.plugins.mybatis.annotation.member.Conditional;
import com.viiyue.plugins.mybatis.enums.ExpressionStyle;
import com.viiyue.plugins.mybatis.enums.NameStyle;
import com.viiyue.plugins.mybatis.enums.Template;
import com.viiyue.plugins.mybatis.enums.ValueStyle;
import com.viiyue.plugins.mybatis.utils.StringUtil;
/**
* Some constants that will be used in the mybatis-mapper plugin
*
* @author tangxbai
* @since 1.1.0
*/
public final class Constants {
// Do not let anyone instantiate this constant class
private Constants() {}
public static final int MAX_CACHE_SIZE = 128;
/** Empty text */
public static final String EMPTY = StringUtil.EMPTY;
public static final String SPACE = StringUtil.SPACE;
/** Template engine default root parameter name : {@value} */
public static final String ROOT_PARAMETER_NAME = "$";
/** Template engine default root scope : {@value} */
public static final String DEFUALT_SCOPE = "this";
/** SQL separator : {@value} */
public static final String SEPARATOR = ", ";
// Order by
/** Order by : {@value} */
public static final String ORDER_BY_ASCENDING = "asc";
/** Order by : {@value} */
public static final String ORDER_BY_ASCENDING_WRAP = "[asc]";
/** Order by : {@value} */
public static final String ORDER_BY_DESCENDING = "desc";
/** Order by : {@value} */
public static final String ORDER_BY_DESCENDING_WRAP = "[desc]";
/** Order by : [ 0"asc", 1"desc", 2"[asc]", 3"[desc]" ] */
public static final String [] ORDERS = { ORDER_BY_ASCENDING, ORDER_BY_DESCENDING, ORDER_BY_ASCENDING_WRAP, ORDER_BY_DESCENDING_WRAP };
// Primary key
/** Primary key placeholder : {@value} */
public static final String PRIMARY_KEY = "#pk";
/** Primary keys placeholder : {@value} */
public static final String PRIMARY_KEYS = "#pks";
// Result map
/** Default base result map reference name : {@value} */
public static final String DEFAULT_RESULT_MAP = "BaseResultMap";
// Conditional
/** Default conditional expression : {@value} */
public static final String DEFAULT_CONDITIONAL = "isNotBlank( this )";
/** Default conditional expression operator holder : {@link Template#Equal Equal} */
public static final Conditional.Holder DEFAULT_CONDITIONAL_HOLDER = Conditional.Holder.Equal;
// Default styles
/** Default name conversion style : {@link NameStyle#UNDERLINE} */
public static final NameStyle DEFAULT_NAME_STYLE = NameStyle.UNDERLINE;
/** Default value conversion style : {@link ValueStyle#SHORT} */
public static final ValueStyle DEFAULT_VALUE_STYLE = ValueStyle.SHORT;
/** Default expression conversion style : {@link ExpressionStyle#SHORT} */
public static final ExpressionStyle DEFAULT_EXPRESSION_STYLE = ExpressionStyle.SHORT;
// Regular expression
/**
* Mybatis parameter regular expression matching pattern
*
#{property, javaType=, jdbcType=}
*/
public static final Pattern MYBATIS_PARAMETER_PATTERN = Pattern.compile( "([#|$])\\{([^\\}].*?)\\}" );
/**
*
Text regular expression matching pattern
*
*
* - -- single line comment
*
- // single line comment
*
- /* inline text comment | multi-line text comment */
*
*/
public static final Pattern TEXT_COMMENTS_PATTERN = Pattern.compile( "(?ms)(('(?:''|[^'])*')|--.*?$|//.*?$|/\\*.*?\\*/)" );
// Environment
/**
* Template engine default environment variable names
*
*
*
* Type name
* variable name
* Example
*
*
* Operating system
*
* osName (e.g., Windos 7)
* osVersion (e.g., 6.1)
* osArch (e.g., amd64)
*
* Region
*
* userTimezone (e.g., Windos)
* userCountry (e.g., CN)
* userLanguage (e.g., zh)
*
* Java informations
*
* javaVersion (e.g., 1.8.0_66)
* javaSpecificationVersion (e.g., 1.8)
*
* File informations
*
* fileEncoding (e.g., UTF-8)
* fileSeparator (e.g., \)
* lineSeparator (e.g., \n)
* pathSeparator (e.g., ;)
*
*/
public static final List ENV_PROP_NAMES = Arrays.asList(
"os.name", "os.version", "os.arch", // osName, osVersion, osArch
"user.timezone", "user.country", "user.language", // userTimezone, userCountry, userLanguage
"java.version", "java.specification.version", // javaVersion, javaSpecificationVersion
"file.encoding", "file.separator", "line.separator", "path.separator" // fieldEncoding, fildSeparator, lineSeparator, pathSeparator
);
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy