public class MysqlSchemaCodegen extends DefaultCodegen implements CodegenConfig
| Modifier and Type | Field and Description |
|---|---|
static String |
CODEGEN_VENDOR_EXTENSION_KEY |
protected String |
columnNamePrefix |
protected String |
columnNameSuffix |
protected String |
databaseNamePrefix |
protected String |
databaseNameSuffix |
static String |
DEFAULT_DATABASE_NAME |
protected String |
defaultDatabaseName |
static Integer |
ENUM_MAX_ELEMENTS |
static Integer |
IDENTIFIER_MAX_LENGTH |
static String |
JSON_DATA_TYPE_ENABLED |
protected Boolean |
jsonDataTypeEnabled |
protected Vector<String> |
mysqlDateAndTimeTypes |
protected Vector<String> |
mysqlNumericTypes |
protected Vector<String> |
mysqlSpatialTypes |
protected Vector<String> |
mysqlStringTypes |
protected String |
tableNamePrefix |
protected String |
tableNameSuffix |
additionalProperties, allowUnicodeIdentifiers, apiDocTemplateFiles, apiPackage, apiTemplateFiles, apiTestTemplateFiles, cliOptions, commonTemplateDir, defaultIncludes, docExtension, embeddedTemplateDir, enableMinimalUpdate, enablePostProcessFile, ensureUniqueParams, fileSuffix, generatorMetadata, gitRepoId, gitUserId, hideGenerationTimestamp, httpUserAgent, ignoreFilePathOverride, importMapping, inputSpec, instantiationTypes, languageSpecificPrimitives, library, modelDocTemplateFiles, modelNamePrefix, modelNameSuffix, modelPackage, modelTemplateFiles, modelTestTemplateFiles, openAPI, outputFolder, prependFormOrBodyParameters, releaseNote, removeOperationIdPrefix, reservedWords, reservedWordsMappings, skipOverwrite, sortParamsByRequiredFlag, specialCharReplacements, strictSpecBehavior, supportedLibraries, supportingFiles, supportsInheritance, supportsMixins, supportsMultipleInheritance, templateDir, testPackage, typeAliases, typeMapping, vendorExtensions| Constructor and Description |
|---|
MysqlSchemaCodegen() |
| Modifier and Type | Method and Description |
|---|---|
String |
escapeMysqlQuotedIdentifier(String identifier)
Escapes MySQL identifier to use it in SQL statements with backticks, eg.
|
String |
escapeMysqlUnquotedIdentifier(String identifier)
Escapes MySQL identifier to use it in SQL statements without backticks, eg.
|
String |
escapeQuotationMark(String input)
Escape single and/or double quote to avoid code injection
|
String |
escapeReservedWord(String name)
Return the escaped name of the reserved word
|
String |
escapeUnsafeCharacters(String input)
override with any special text escaping logic to handle unsafe
characters so as to avoid code injection
|
String |
getDefaultDatabaseName()
Returns default database name for all MySQL queries
This value must be used with backticks only, eg.
|
String |
getHelp() |
Boolean |
getJsonDataTypeEnabled()
Whether JSON data type enabled or disabled in all MySQL queries
|
String |
getMysqlMatchedIntegerDataType(Long minimum,
Long maximum,
Boolean unsigned)
Finds best fitted MySQL data type for integer variable based on minimum and maximum properties
|
String |
getMysqlMatchedStringDataType(Integer minLength,
Integer maxLength)
Finds best fitted MySQL data type for string variable based on minLength and maxLength properties
|
String |
getName() |
CodegenType |
getTag() |
Boolean |
isMysqlDataType(String dataType)
Checks whether string is one of MySQL Data Types
Ref: https://dev.mysql.com/doc/refman/8.0/en/data-type-overview.html
|
void |
postProcessModelProperty(CodegenModel model,
CodegenProperty property) |
Map<String,Object> |
postProcessModels(Map<String,Object> objs) |
void |
processBooleanTypeProperty(CodegenModel model,
CodegenProperty property)
Processes each model's property mapped to boolean type and adds related vendor extensions
|
void |
processDateTypeProperty(CodegenModel model,
CodegenProperty property)
Processes each model's property mapped to date type and adds related vendor extensions
|
void |
processDecimalTypeProperty(CodegenModel model,
CodegenProperty property)
Processes each model's property mapped to decimal type and adds related vendor extensions
|
void |
processIntegerTypeProperty(CodegenModel model,
CodegenProperty property)
Processes each model's property mapped to integer type and adds related vendor extensions
|
void |
processJsonTypeProperty(CodegenModel model,
CodegenProperty property)
Processes each model's property mapped to JSON type and adds related vendor extensions
|
void |
processOpts() |
void |
processStringTypeProperty(CodegenModel model,
CodegenProperty property)
Processes each model's property mapped to string type and adds related vendor extensions
|
void |
processUnknownTypeProperty(CodegenModel model,
CodegenProperty property)
Processes each model's property not mapped to any type and adds related vendor extensions
Most of time it's related to referenced properties eg.
|
void |
setDefaultDatabaseName(String databaseName)
Sets default database name for all MySQL queries
Provided value will be escaped when necessary
|
void |
setJsonDataTypeEnabled(Boolean enabled)
Enables special JSON data type in all MySQL queries
JSON data type requires MySQL version 5.7.8
|
HashMap<String,Object> |
toCodegenMysqlDataTypeArgument(Object value,
Boolean hasMore)
Generates codegen property for MySQL data type argument
|
HashMap<String,Object> |
toCodegenMysqlDataTypeDefault(String defaultValue,
String mysqlDataType)
Generates default codegen property for MySQL column definition
Ref: https://dev.mysql.com/doc/refman/5.7/en/data-type-defaults.html
|
String |
toColumnName(String name)
Converts name to valid MySQL column name
Produced name must be used with backticks only, eg.
|
String |
toDatabaseName(String name)
Converts name to valid MySQL database name
Produced name must be used with backticks only, eg.
|
String |
toMysqlIdentifier(String name,
String prefix,
String suffix)
Converts name to valid MySQL identifier which can be used as database, table, column name
Produced name must be used with backticks only, eg.
|
String |
toTableName(String name)
Converts name to valid MySQL column name
Produced name must be used with backticks only, eg.
|
addAdditionPropertiesToCodeGenModel, addImport, additionalProperties, addOperationToGroup, addOption, addProperties, addRegularExpressionDelimiter, addSwitch, apiDocFileFolder, apiDocFilename, apiDocTemplateFiles, apiFileFolder, apiFilename, apiPackage, apiTemplateFiles, apiTestFileFolder, apiTestFilename, apiTestTemplateFiles, buildLibraryCliOption, cliOptions, convertPropertyToBoolean, convertPropertyToBooleanAndWriteBack, defaultIncludes, embeddedTemplateDir, encodePath, escapeText, escapeTextWhileAllowingNewLines, fileSuffix, findCommonPrefixOfVars, findMethodResponse, fromCallback, fromFormProperty, fromModel, fromOperation, fromParameter, fromProperty, fromRequestBody, fromRequestBodyToFormParameters, fromResponse, fromSecurity, fromServers, fromServerVariables, generateExamplePath, generateJSONSpecFile, generateYAMLSpecFile, getAlias, getAllowUnicodeIdentifiers, getCollectionFormat, getCommonTemplateDir, getConsumesInfo, getContentType, getDocExtension, getEnsureUniqueParams, getGeneratorMetadata, getGitRepoId, getGitUserId, getHttpUserAgent, getIgnoreFilePathOverride, getInnerEnumAllowableValues, getInputSpec, getLibrary, getModelNamePrefix, getModelNameSuffix, getMostInnerItems, getOrGenerateOperationId, getOutputDir, getParameterDataType, getPrependFormOrBodyParameters, getProducesInfo, getReleaseNote, getSchemaType, getSortParamsByRequiredFlag, getSymbolName, getTemplatingEngine, getterAndSetterCapitalize, getTypeDeclaration, getTypeDeclaration, hasBodyParameter, hasFormParameter, importMapping, initalizeSpecialCharacterMapping, instantiationTypes, isDataTypeBinary, isDataTypeFile, isDataTypeString, isEnableMinimalUpdate, isEnablePostProcessFile, isHideGenerationTimestamp, isParameterNameUnique, isPropertyInnerMostEnum, isRemoveOperationIdPrefix, isReservedWord, isSkipOverwrite, isStrictSpecBehavior, languageSpecificPrimitives, modelDocFileFolder, modelDocTemplateFiles, modelFileFolder, modelPackage, modelTemplateFiles, modelTestFileFolder, modelTestTemplateFiles, needToImport, outputFolder, postProcessAllModels, postProcessFile, postProcessModelsEnum, postProcessOperationsWithModels, postProcessParameter, postProcessSupportingFileData, preprocessOpenAPI, processCompiler, processOpenAPI, processTemplatingEngine, removeNonNameElementToCamelCase, removeNonNameElementToCamelCase, reservedWords, reservedWordsMappings, sanitizeName, sanitizeName, sanitizeTag, setAllowUnicodeIdentifiers, setApiPackage, setCommonTemplateDir, setDocExtension, setEnableMinimalUpdate, setEnablePostProcessFile, setEnsureUniqueParams, setGitRepoId, setGitUserId, setHideGenerationTimestamp, setHttpUserAgent, setIgnoreFilePathOverride, setInputSpec, setLibrary, setModelNamePrefix, setModelNameSuffix, setModelPackage, setNonArrayMapProperty, setOpenAPI, setOutputDir, setParameterBooleanFlagWithCodegenProperty, setParameterExampleValue, setParameterExampleValue, setParameterExampleValue, setPrependFormOrBodyParameters, setReleaseNote, setRemoveOperationIdPrefix, setReservedWordsLowerCase, setSkipOverwrite, setSortParamsByRequiredFlag, setStrictSpecBehavior, setTemplateDir, setTemplatingEngine, shouldOverwrite, snakeCase, supportedLibraries, supportingFiles, templateDir, testPackage, toAllOfName, toAnyOfName, toApiDocFilename, toApiFilename, toApiImport, toApiName, toApiTestFilename, toApiVarName, toArrayModelParamName, toBooleanGetter, toDefaultValue, toDefaultValueWithParam, toEnumDefaultValue, toEnumName, toEnumValue, toEnumVarName, toExamples, toExampleValue, toGetter, toInstantiationType, toModelDocFilename, toModelFilename, toModelImport, toModelName, toModelTestFilename, toOneOfName, toOperationId, toParamName, toRegularExpression, toSetter, toVarName, typeMapping, updateAllModels, updateCodegenPropertyEnum, updateDataTypeWithEnumForArray, updateDataTypeWithEnumForMap, updateOption, updatePropertyForArray, updatePropertyForMap, vendorExtensions, writeOptional, writePropertyBackclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitadditionalProperties, addOperationToGroup, apiDocFileFolder, apiDocFilename, apiDocTemplateFiles, apiFileFolder, apiFilename, apiPackage, apiTemplateFiles, apiTestFileFolder, apiTestFilename, apiTestTemplateFiles, cliOptions, defaultIncludes, embeddedTemplateDir, encodePath, escapeText, escapeTextWhileAllowingNewLines, fileSuffix, fromModel, fromOperation, fromSecurity, fromServers, fromServerVariables, generateExamplePath, getCommonTemplateDir, getDocExtension, getGeneratorMetadata, getGitRepoId, getGitUserId, getHttpUserAgent, getIgnoreFilePathOverride, getInputSpec, getLibrary, getOutputDir, getReleaseNote, getTemplatingEngine, getTypeDeclaration, getTypeDeclaration, importMapping, instantiationTypes, isEnableMinimalUpdate, isEnablePostProcessFile, isHideGenerationTimestamp, isRemoveOperationIdPrefix, isSkipOverwrite, isStrictSpecBehavior, languageSpecificPrimitives, modelDocFileFolder, modelDocTemplateFiles, modelFileFolder, modelPackage, modelTemplateFiles, modelTestFileFolder, modelTestTemplateFiles, outputFolder, postProcessAllModels, postProcessFile, postProcessOperationsWithModels, postProcessParameter, postProcessSupportingFileData, preprocessOpenAPI, processCompiler, processOpenAPI, processTemplatingEngine, reservedWords, reservedWordsMappings, sanitizeName, sanitizeTag, setDocExtension, setEnableMinimalUpdate, setEnablePostProcessFile, setGitRepoId, setGitUserId, setHideGenerationTimestamp, setHttpUserAgent, setIgnoreFilePathOverride, setInputSpec, setLibrary, setOpenAPI, setOutputDir, setReleaseNote, setRemoveOperationIdPrefix, setSkipOverwrite, setStrictSpecBehavior, setTemplatingEngine, shouldOverwrite, supportedLibraries, supportingFiles, templateDir, testPackage, toApiDocFilename, toApiFilename, toApiImport, toApiName, toApiTestFilename, toApiVarName, toBooleanGetter, toGetter, toModelDocFilename, toModelFilename, toModelImport, toModelName, toModelTestFilename, toParamName, toSetter, typeMapping, updateAllModels, vendorExtensionspublic static final String CODEGEN_VENDOR_EXTENSION_KEY
public static final String DEFAULT_DATABASE_NAME
public static final String JSON_DATA_TYPE_ENABLED
public static final Integer ENUM_MAX_ELEMENTS
public static final Integer IDENTIFIER_MAX_LENGTH
protected String defaultDatabaseName
protected String databaseNamePrefix
protected String databaseNameSuffix
protected String tableNamePrefix
protected String tableNameSuffix
protected String columnNamePrefix
protected String columnNameSuffix
protected Boolean jsonDataTypeEnabled
public CodegenType getTag()
getTag in interface CodegenConfiggetTag in class DefaultCodegenpublic String getName()
getName in interface CodegenConfiggetName in class DefaultCodegenpublic String getHelp()
getHelp in interface CodegenConfiggetHelp in class DefaultCodegenpublic void processOpts()
processOpts in interface CodegenConfigprocessOpts in class DefaultCodegenpublic Map<String,Object> postProcessModels(Map<String,Object> objs)
postProcessModels in interface CodegenConfigpostProcessModels in class DefaultCodegenpublic void postProcessModelProperty(CodegenModel model, CodegenProperty property)
postProcessModelProperty in interface CodegenConfigpostProcessModelProperty in class DefaultCodegenpublic void processIntegerTypeProperty(CodegenModel model, CodegenProperty property)
model - modelproperty - model's propertypublic void processDecimalTypeProperty(CodegenModel model, CodegenProperty property)
model - modelproperty - model's propertypublic void processBooleanTypeProperty(CodegenModel model, CodegenProperty property)
model - modelproperty - model's propertypublic void processStringTypeProperty(CodegenModel model, CodegenProperty property)
model - modelproperty - model's propertypublic void processDateTypeProperty(CodegenModel model, CodegenProperty property)
model - modelproperty - model's propertypublic void processJsonTypeProperty(CodegenModel model, CodegenProperty property)
model - modelproperty - model's propertypublic void processUnknownTypeProperty(CodegenModel model, CodegenProperty property)
model - modelproperty - model's propertypublic HashMap<String,Object> toCodegenMysqlDataTypeArgument(Object value, Boolean hasMore)
value - argument valuehasMore - shows whether codegen has more arguments or notpublic HashMap<String,Object> toCodegenMysqlDataTypeDefault(String defaultValue, String mysqlDataType)
defaultValue - valuemysqlDataType - MySQL data typepublic String getMysqlMatchedIntegerDataType(Long minimum, Long maximum, Boolean unsigned)
minimum - (optional) codegen propertymaximum - (optional) codegen propertyunsigned - (optional) whether variable is unsigned or notpublic String getMysqlMatchedStringDataType(Integer minLength, Integer maxLength)
minLength - (optional) codegen propertymaxLength - (optional) codegen propertypublic Boolean isMysqlDataType(String dataType)
dataType - which needs to checkpublic String toDatabaseName(String name)
name - source namepublic String toTableName(String name)
name - source namepublic String toColumnName(String name)
name - source namepublic String toMysqlIdentifier(String name, String prefix, String suffix)
name - source nameprefix - when escaped name is digits only, prefix will be prependedsuffix - when escaped name is digits only, suffix will be appendedpublic String escapeMysqlUnquotedIdentifier(String identifier)
identifier - source identifierpublic String escapeMysqlQuotedIdentifier(String identifier)
identifier - source identifierpublic String escapeReservedWord(String name)
DefaultCodegenescapeReservedWord in interface CodegenConfigescapeReservedWord in class DefaultCodegenname - the name to be escapedthrows Runtime exception as reserved word is not allowed (default behavior)
public String escapeQuotationMark(String input)
DefaultCodegenescapeQuotationMark in interface CodegenConfigescapeQuotationMark in class DefaultCodegeninput - String to be cleaned uppublic String escapeUnsafeCharacters(String input)
DefaultCodegenescapeUnsafeCharacters in interface CodegenConfigescapeUnsafeCharacters in class DefaultCodegeninput - String to be cleaned uppublic void setDefaultDatabaseName(String databaseName)
databaseName - source namepublic String getDefaultDatabaseName()
public void setJsonDataTypeEnabled(Boolean enabled)
enabled - true to enable, otherwise falsepublic Boolean getJsonDataTypeEnabled()
Copyright © 2019. All rights reserved.