public class EqualsHashCodePlugin extends PluginAdapter
The equals
method generated by this class is correct in most cases,
but will probably NOT be correct if you have specified a rootClass - because
our equals method only checks the fields it knows about.
Similarly, the hashCode
method generated by this class only relies
on fields it knows about. Anything you add, or fields in a super class will
not be factored into the hash code.
Plugin.ModelClassType
context, properties
Constructor and Description |
---|
EqualsHashCodePlugin() |
Modifier and Type | Method and Description |
---|---|
protected void |
generateEquals(TopLevelClass topLevelClass,
List<IntrospectedColumn> introspectedColumns,
IntrospectedTable introspectedTable)
Generates an
equals method that does a comparison of all fields. |
protected void |
generateHashCode(TopLevelClass topLevelClass,
List<IntrospectedColumn> introspectedColumns,
IntrospectedTable introspectedTable)
Generates a
hashCode method that includes all fields. |
boolean |
modelBaseRecordClassGenerated(TopLevelClass topLevelClass,
IntrospectedTable introspectedTable)
This method is called after the base record class is generated by the
JavaModelGenerator.
|
boolean |
modelPrimaryKeyClassGenerated(TopLevelClass topLevelClass,
IntrospectedTable introspectedTable)
This method is called after the primary key class is generated by the
JavaModelGenerator.
|
boolean |
modelRecordWithBLOBsClassGenerated(TopLevelClass topLevelClass,
IntrospectedTable introspectedTable)
This method is called after the record with BLOBs class is generated by
the JavaModelGenerator.
|
void |
setProperties(Properties properties)
Set properties from the plugin configuration.
|
boolean |
validate(List<String> warnings)
This plugin is always valid - no properties are required.
|
setContext
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
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, kotlinDataClassGenerated, mapperExtensionsGenerated, mapperGenerated, modelExampleClassGenerated, modelFieldGenerated, modelGetterMethodGenerated, modelSetterMethodGenerated, providerApplyWhereMethodGenerated, providerCountByExampleMethodGenerated, providerDeleteByExampleMethodGenerated, providerGenerated, providerInsertSelectiveMethodGenerated, providerSelectByExampleWithBLOBsMethodGenerated, providerSelectByExampleWithoutBLOBsMethodGenerated, providerUpdateByExampleSelectiveMethodGenerated, providerUpdateByExampleWithBLOBsMethodGenerated, providerUpdateByExampleWithoutBLOBsMethodGenerated, providerUpdateByPrimaryKeySelectiveMethodGenerated, sqlMapBaseColumnListElementGenerated, sqlMapBlobColumnListElementGenerated, sqlMapCountByExampleElementGenerated, sqlMapDeleteByExampleElementGenerated, sqlMapDeleteByPrimaryKeyElementGenerated, sqlMapDocumentGenerated, sqlMapExampleWhereClauseElementGenerated, sqlMapGenerated, sqlMapInsertElementGenerated, sqlMapInsertSelectiveElementGenerated, sqlMapResultMapWithBLOBsElementGenerated, sqlMapResultMapWithoutBLOBsElementGenerated, sqlMapSelectAllElementGenerated, sqlMapSelectByExampleWithBLOBsElementGenerated, sqlMapSelectByExampleWithoutBLOBsElementGenerated, sqlMapSelectByPrimaryKeyElementGenerated, sqlMapUpdateByExampleSelectiveElementGenerated, sqlMapUpdateByExampleWithBLOBsElementGenerated, sqlMapUpdateByExampleWithoutBLOBsElementGenerated, sqlMapUpdateByPrimaryKeySelectiveElementGenerated, sqlMapUpdateByPrimaryKeyWithBLOBsElementGenerated, sqlMapUpdateByPrimaryKeyWithoutBLOBsElementGenerated
public void setProperties(Properties properties)
Plugin
setProperties
in interface Plugin
setProperties
in class PluginAdapter
properties
- the new propertiespublic boolean validate(List<String> warnings)
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.public boolean modelBaseRecordClassGenerated(TopLevelClass topLevelClass, IntrospectedTable introspectedTable)
Plugin
topLevelClass
- the generated base record classintrospectedTable
- The class containing information about the table as
introspected from the databasepublic boolean modelPrimaryKeyClassGenerated(TopLevelClass topLevelClass, IntrospectedTable introspectedTable)
Plugin
topLevelClass
- the generated primary key classintrospectedTable
- The class containing information about the table as
introspected from the databasepublic boolean modelRecordWithBLOBsClassGenerated(TopLevelClass topLevelClass, IntrospectedTable introspectedTable)
Plugin
topLevelClass
- the generated record with BLOBs classintrospectedTable
- The class containing information about the table as
introspected from the databaseprotected void generateEquals(TopLevelClass topLevelClass, List<IntrospectedColumn> introspectedColumns, IntrospectedTable introspectedTable)
equals
method that does a comparison of all fields.
The generated equals
method will be correct unless:
rootClass
is specified that holds statetopLevelClass
- the class to which the method will be addedintrospectedColumns
- column definitions of this class and any superclass of this
classintrospectedTable
- the table corresponding to this classprotected void generateHashCode(TopLevelClass topLevelClass, List<IntrospectedColumn> introspectedColumns, IntrospectedTable introspectedTable)
hashCode
method that includes all fields.
Note that this implementation is based on the eclipse foundation hashCode generator.
topLevelClass
- the class to which the method will be addedintrospectedColumns
- column definitions of this class and any superclass of this
classintrospectedTable
- the table corresponding to this classCopyright © 2006–2023 MyBatis.org. All rights reserved.