Package org.mybatis.generator.plugins
Class SerializablePlugin
java.lang.Object
org.mybatis.generator.api.PluginAdapter
org.mybatis.generator.plugins.SerializablePlugin
- All Implemented Interfaces:
Plugin
This plugin adds the java.io.Serializable marker interface to all generated
model objects.
This plugin demonstrates adding capabilities to generated Java artifacts, and shows the proper way to add imports to a compilation unit.
Important: This is a simplistic implementation of serializable and does not attempt to do any versioning of classes.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.mybatis.generator.api.Plugin
Plugin.ModelClassType -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanprivate final FullyQualifiedJavaTypeprivate final FullyQualifiedJavaTypeprivate booleanFields inherited from class org.mybatis.generator.api.PluginAdapter
context, properties -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleankotlinDataClassGenerated(KotlinFile kotlinFile, KotlinType dataClass, IntrospectedTable introspectedTable) protected voidmakeSerializable(TopLevelClass topLevelClass, IntrospectedTable introspectedTable) booleanmodelBaseRecordClassGenerated(TopLevelClass topLevelClass, IntrospectedTable introspectedTable) This method is called after the base record class is generated by the JavaModelGenerator.booleanmodelPrimaryKeyClassGenerated(TopLevelClass topLevelClass, IntrospectedTable introspectedTable) This method is called after the primary key class is generated by the JavaModelGenerator.booleanmodelRecordWithBLOBsClassGenerated(TopLevelClass topLevelClass, IntrospectedTable introspectedTable) This method is called after the record with BLOBs class is generated by the JavaModelGenerator.voidsetProperties(Properties properties) Set properties from the plugin configuration.booleanThis method is called after all the setXXX methods are called, but before any other method is called.Methods inherited from class org.mybatis.generator.api.PluginAdapter
setContextMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.mybatis.generator.api.Plugin
clientBasicCountMethodGenerated, clientBasicCountMethodGenerated, clientBasicDeleteMethodGenerated, clientBasicDeleteMethodGenerated, clientBasicInsertMethodGenerated, clientBasicInsertMethodGenerated, clientBasicInsertMultipleHelperMethodGenerated, clientBasicInsertMultipleHelperMethodGenerated, clientBasicInsertMultipleMethodGenerated, clientBasicInsertMultipleMethodGenerated, clientBasicSelectManyMethodGenerated, clientBasicSelectManyMethodGenerated, clientBasicSelectOneMethodGenerated, clientBasicSelectOneMethodGenerated, clientBasicUpdateMethodGenerated, clientBasicUpdateMethodGenerated, clientColumnListPropertyGenerated, clientCountByExampleMethodGenerated, clientDeleteByExampleMethodGenerated, clientDeleteByPrimaryKeyMethodGenerated, clientDeleteByPrimaryKeyMethodGenerated, clientGeneralCountMethodGenerated, clientGeneralCountMethodGenerated, clientGeneralDeleteMethodGenerated, clientGeneralDeleteMethodGenerated, clientGeneralSelectDistinctMethodGenerated, clientGeneralSelectDistinctMethodGenerated, clientGeneralSelectMethodGenerated, clientGeneralSelectMethodGenerated, clientGeneralUpdateMethodGenerated, clientGeneralUpdateMethodGenerated, clientGenerated, clientInsertMethodGenerated, clientInsertMethodGenerated, clientInsertMultipleMethodGenerated, clientInsertMultipleMethodGenerated, clientInsertMultipleVarargMethodGenerated, clientInsertSelectiveMethodGenerated, clientInsertSelectiveMethodGenerated, clientSelectAllMethodGenerated, clientSelectByExampleWithBLOBsMethodGenerated, clientSelectByExampleWithoutBLOBsMethodGenerated, clientSelectByPrimaryKeyMethodGenerated, clientSelectByPrimaryKeyMethodGenerated, clientSelectListFieldGenerated, clientSelectOneMethodGenerated, clientSelectOneMethodGenerated, clientUpdateAllColumnsMethodGenerated, clientUpdateAllColumnsMethodGenerated, clientUpdateByExampleSelectiveMethodGenerated, clientUpdateByExampleWithBLOBsMethodGenerated, clientUpdateByExampleWithoutBLOBsMethodGenerated, clientUpdateByPrimaryKeyMethodGenerated, clientUpdateByPrimaryKeySelectiveMethodGenerated, clientUpdateByPrimaryKeySelectiveMethodGenerated, clientUpdateByPrimaryKeyWithBLOBsMethodGenerated, clientUpdateByPrimaryKeyWithoutBLOBsMethodGenerated, clientUpdateSelectiveColumnsMethodGenerated, clientUpdateSelectiveColumnsMethodGenerated, contextGenerateAdditionalFiles, contextGenerateAdditionalFiles, contextGenerateAdditionalJavaFiles, contextGenerateAdditionalJavaFiles, contextGenerateAdditionalKotlinFiles, contextGenerateAdditionalKotlinFiles, contextGenerateAdditionalXmlFiles, contextGenerateAdditionalXmlFiles, dynamicSqlSupportGenerated, dynamicSqlSupportGenerated, initialized, mapperExtensionsGenerated, mapperGenerated, modelExampleClassGenerated, modelFieldGenerated, modelGetterMethodGenerated, modelSetterMethodGenerated, providerApplyWhereMethodGenerated, providerCountByExampleMethodGenerated, providerDeleteByExampleMethodGenerated, providerGenerated, providerInsertSelectiveMethodGenerated, providerSelectByExampleWithBLOBsMethodGenerated, providerSelectByExampleWithoutBLOBsMethodGenerated, providerUpdateByExampleSelectiveMethodGenerated, providerUpdateByExampleWithBLOBsMethodGenerated, providerUpdateByExampleWithoutBLOBsMethodGenerated, providerUpdateByPrimaryKeySelectiveMethodGenerated, shouldGenerate, sqlMapBaseColumnListElementGenerated, sqlMapBlobColumnListElementGenerated, sqlMapCountByExampleElementGenerated, sqlMapDeleteByExampleElementGenerated, sqlMapDeleteByPrimaryKeyElementGenerated, sqlMapDocumentGenerated, sqlMapExampleWhereClauseElementGenerated, sqlMapGenerated, sqlMapInsertElementGenerated, sqlMapInsertSelectiveElementGenerated, sqlMapResultMapWithBLOBsElementGenerated, sqlMapResultMapWithoutBLOBsElementGenerated, sqlMapSelectAllElementGenerated, sqlMapSelectByExampleWithBLOBsElementGenerated, sqlMapSelectByExampleWithoutBLOBsElementGenerated, sqlMapSelectByPrimaryKeyElementGenerated, sqlMapUpdateByExampleSelectiveElementGenerated, sqlMapUpdateByExampleWithBLOBsElementGenerated, sqlMapUpdateByExampleWithoutBLOBsElementGenerated, sqlMapUpdateByPrimaryKeySelectiveElementGenerated, sqlMapUpdateByPrimaryKeyWithBLOBsElementGenerated, sqlMapUpdateByPrimaryKeyWithoutBLOBsElementGenerated
-
Field Details
-
serializable
-
gwtSerializable
-
addGWTInterface
private boolean addGWTInterface -
suppressJavaInterface
private boolean suppressJavaInterface
-
-
Constructor Details
-
SerializablePlugin
public SerializablePlugin()
-
-
Method Details
-
validate
Description copied from interface:PluginThis method is called after all the setXXX methods are called, but before any other method is called. This allows the plugin to determine whether it can run or not. For example, if the plugin requires certain properties to be set, and the properties are not set, then the plugin is invalid and will not run.- Parameters:
warnings- add strings to this list to specify warnings. For example, if the plugin is invalid, you should specify why. Warnings are reported to users after the completion of the run.- Returns:
- true if the plugin is in a valid state. Invalid plugins will not be called
-
setProperties
Description copied from interface:PluginSet properties from the plugin configuration.- Specified by:
setPropertiesin interfacePlugin- Overrides:
setPropertiesin classPluginAdapter- Parameters:
properties- the new properties
-
modelBaseRecordClassGenerated
public boolean modelBaseRecordClassGenerated(TopLevelClass topLevelClass, IntrospectedTable introspectedTable) Description copied from interface:PluginThis method is called after the base record class is generated by the JavaModelGenerator. This method will only be called if the table rules call for generation of a base record class.
This method is only guaranteed to be called by the default Java model generators. Other user supplied generators may, or may not, call this method.- Parameters:
topLevelClass- the generated base record classintrospectedTable- The class containing information about the table as introspected from the database- Returns:
- true if the class should be generated, false if the generated class should be ignored. In the case of multiple plugins, the first plugin returning false will disable the calling of further plugins.
-
modelPrimaryKeyClassGenerated
public boolean modelPrimaryKeyClassGenerated(TopLevelClass topLevelClass, IntrospectedTable introspectedTable) Description copied from interface:PluginThis method is called after the primary key class is generated by the JavaModelGenerator. This method will only be called if the table rules call for generation of a primary key class.
This method is only guaranteed to be called by the Java model generators. Other user supplied generators may, or may not, call this method.- Parameters:
topLevelClass- the generated primary key classintrospectedTable- The class containing information about the table as introspected from the database- Returns:
- true if the class should be generated, false if the generated class should be ignored. In the case of multiple plugins, the first plugin returning false will disable the calling of further plugins.
-
modelRecordWithBLOBsClassGenerated
public boolean modelRecordWithBLOBsClassGenerated(TopLevelClass topLevelClass, IntrospectedTable introspectedTable) Description copied from interface:PluginThis method is called after the record with BLOBs class is generated by the JavaModelGenerator. This method will only be called if the table rules call for generation of a record with BLOBs class.
This method is only guaranteed to be called by the default Java model generators. Other user supplied generators may, or may not, call this method.- Parameters:
topLevelClass- the generated record with BLOBs classintrospectedTable- The class containing information about the table as introspected from the database- Returns:
- true if the class should be generated, false if the generated class should be ignored. In the case of multiple plugins, the first plugin returning false will disable the calling of further plugins.
-
makeSerializable
-
kotlinDataClassGenerated
public boolean kotlinDataClassGenerated(KotlinFile kotlinFile, KotlinType dataClass, IntrospectedTable introspectedTable)
-