Class RulesDelegate
java.lang.Object
org.mybatis.generator.internal.rules.RulesDelegate
- All Implemented Interfaces:
Rules
This class can be used by plugins to easily implement a custom rules
implementation. Plugins should respect the rules implementation calculated by
the generator, as well as implementations from other plugins. In general if
something is disabled by the default rules, or is disabled by some other
plugin, it should not be re-enabled. Therefore, the following pattern of use
is recommended:
public class MyPlugin extends PluginAdapter {
@Override
public void initialized(IntrospectedTable introspectedTable) {
MyRules myRules = new MyRules(introspectedTable.getRules());
introspectedTable.setRules(myRules);
}
}
public class MyRules extends RulesDelegate (
public MyRules(Rules rules) {
super(rules);
}
@Override
public boolean generateInsert() {
boolean rc = super.generateInsert();
if (rc) {
// Other plugins, and the default rules, enable generation
// of the insert method. We can decide to disable it here
// if needed.
}
return rc;
}
- Author:
- Jeff Butler
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionCalculates the class that contains all fields.booleanImplements the rule for generating the SQL base column list element.booleanImplements the rule for generating a base record.booleanImplements the rule for generating the result map without BLOBs.booleanImplements the rule for generating the SQL blob column list element.booleanbooleanImplements the rule for generating the delete by example SQL Map element and DAO method.booleanImplements the rule for generating the delete by primary key SQL Map element and DAO method.booleanImplements the rule for generating an example class.booleanImplements the rule for generating the insert SQL Map element and DAO method.booleanImplements the rule for generating the insert selective SQL Map element and DAO method.booleanImplements the rule for generating a Java client.booleanImplements the rule for generating the SQL example where clause element specifically for use in the update by example methods.booleanImplements the rule for determining whether to generate a primary key class.booleanImplements the rule for generating a record with BLOBs.booleanImplements the rule for generating the result map with BLOBs.booleanImplements the rule for generating the select by example with BLOBs SQL Map element and DAO method.booleanImplements the rule for generating the select by example without BLOBs SQL Map element and DAO method.booleanImplements the rule for generating the select by primary key SQL Map element and DAO method.booleanImplements the rule for generating the SQL example where clause element.booleanbooleanbooleanbooleanImplements the rule for generating the update by primary key selective SQL Map element and DAO method.booleanImplements the rule for generating the update by primary key with BLOBs SQL Map element and DAO method.booleanImplements the rule for generating the update by primary key without BLOBs SQL Map element and DAO method.
-
Field Details
-
rules
-
-
Constructor Details
-
RulesDelegate
-
-
Method Details
-
calculateAllFieldsClass
Description copied from interface:RulesCalculates the class that contains all fields. This class is used as the insert statement parameter, as well as the returned value from the select by primary key method. The actual class depends on how the domain model is generated.- Specified by:
calculateAllFieldsClassin interfaceRules- Returns:
- the type of the class that holds all fields
-
generateBaseRecordClass
public boolean generateBaseRecordClass()Description copied from interface:RulesImplements the rule for generating a base record.- Specified by:
generateBaseRecordClassin interfaceRules- Returns:
- true if the class should be generated
-
generateBaseResultMap
public boolean generateBaseResultMap()Description copied from interface:RulesImplements the rule for generating the result map without BLOBs. If either select method is allowed, then generate the result map.- Specified by:
generateBaseResultMapin interfaceRules- Returns:
- true if the result map should be generated
-
generateCountByExample
public boolean generateCountByExample()- Specified by:
generateCountByExamplein interfaceRules
-
generateDeleteByExample
public boolean generateDeleteByExample()Description copied from interface:RulesImplements the rule for generating the delete by example SQL Map element and DAO method. If the deleteByExample statement is allowed, then generate the element and method.- Specified by:
generateDeleteByExamplein interfaceRules- Returns:
- true if the element and method should be generated
-
generateDeleteByPrimaryKey
public boolean generateDeleteByPrimaryKey()Description copied from interface:RulesImplements the rule for generating the delete by primary key SQL Map element and DAO method. If the table has a primary key, and the deleteByPrimaryKey statement is allowed, then generate the element and method.- Specified by:
generateDeleteByPrimaryKeyin interfaceRules- Returns:
- true if the element and method should be generated
-
generateExampleClass
public boolean generateExampleClass()Description copied from interface:RulesImplements the rule for generating an example class. The class should be generated if the selectByExample or deleteByExample or countByExample methods are allowed.- Specified by:
generateExampleClassin interfaceRules- Returns:
- true if the example class should be generated
-
generateInsert
public boolean generateInsert()Description copied from interface:RulesImplements the rule for generating the insert SQL Map element and DAO method. If the insert statement is allowed, then generate the element and method.- Specified by:
generateInsertin interfaceRules- Returns:
- true if the element and method should be generated
-
generateInsertSelective
public boolean generateInsertSelective()Description copied from interface:RulesImplements the rule for generating the insert selective SQL Map element and DAO method. If the insert statement is allowed, then generate the element and method.- Specified by:
generateInsertSelectivein interfaceRules- Returns:
- true if the element and method should be generated
-
generatePrimaryKeyClass
public boolean generatePrimaryKeyClass()Description copied from interface:RulesImplements the rule for determining whether to generate a primary key class. If you return false from this method, and the table has primary key columns, then the primary key columns will be added to the base class.- Specified by:
generatePrimaryKeyClassin interfaceRules- Returns:
- true if a separate primary key class should be generated
-
generateRecordWithBLOBsClass
public boolean generateRecordWithBLOBsClass()Description copied from interface:RulesImplements the rule for generating a record with BLOBs. If you return false from this method, and the table had BLOB columns, then the BLOB columns will be added to the base class.- Specified by:
generateRecordWithBLOBsClassin interfaceRules- Returns:
- true if the record with BLOBs class should be generated
-
generateResultMapWithBLOBs
public boolean generateResultMapWithBLOBs()Description copied from interface:RulesImplements the rule for generating the result map with BLOBs. If the table has BLOB columns, and either select method is allowed, then generate the result map.- Specified by:
generateResultMapWithBLOBsin interfaceRules- Returns:
- true if the result map should be generated
-
generateSelectByExampleWithBLOBs
public boolean generateSelectByExampleWithBLOBs()Description copied from interface:RulesImplements the rule for generating the select by example with BLOBs SQL Map element and DAO method. If the table has BLOB fields and the selectByExample statement is allowed, then generate the element and method.- Specified by:
generateSelectByExampleWithBLOBsin interfaceRules- Returns:
- true if the element and method should be generated
-
generateSelectByExampleWithoutBLOBs
public boolean generateSelectByExampleWithoutBLOBs()Description copied from interface:RulesImplements the rule for generating the select by example without BLOBs SQL Map element and DAO method. If the selectByExample statement is allowed, then generate the element and method.- Specified by:
generateSelectByExampleWithoutBLOBsin interfaceRules- Returns:
- true if the element and method should be generated
-
generateSelectByPrimaryKey
public boolean generateSelectByPrimaryKey()Description copied from interface:RulesImplements the rule for generating the select by primary key SQL Map element and DAO method. If the table has a primary key as well as other fields, and the selectByPrimaryKey statement is allowed, then generate the element and method.- Specified by:
generateSelectByPrimaryKeyin interfaceRules- Returns:
- true if the element and method should be generated
-
generateSQLExampleWhereClause
public boolean generateSQLExampleWhereClause()Description copied from interface:RulesImplements the rule for generating the SQL example where clause element.In MyBatis3, generate the element if the selectByExample, deleteByExample, or countByExample statements are allowed.
- Specified by:
generateSQLExampleWhereClausein interfaceRules- Returns:
- true if the SQL where clause element should be generated
-
generateMyBatis3UpdateByExampleWhereClause
public boolean generateMyBatis3UpdateByExampleWhereClause()Description copied from interface:RulesImplements the rule for generating the SQL example where clause element specifically for use in the update by example methods.In MyBatis, generate the element if the updateByExample statements are allowed.
- Specified by:
generateMyBatis3UpdateByExampleWhereClausein interfaceRules- Returns:
- true if the SQL where clause element should be generated
-
generateUpdateByExampleSelective
public boolean generateUpdateByExampleSelective()- Specified by:
generateUpdateByExampleSelectivein interfaceRules
-
generateUpdateByExampleWithBLOBs
public boolean generateUpdateByExampleWithBLOBs()- Specified by:
generateUpdateByExampleWithBLOBsin interfaceRules
-
generateUpdateByExampleWithoutBLOBs
public boolean generateUpdateByExampleWithoutBLOBs()- Specified by:
generateUpdateByExampleWithoutBLOBsin interfaceRules
-
generateUpdateByPrimaryKeySelective
public boolean generateUpdateByPrimaryKeySelective()Description copied from interface:RulesImplements the rule for generating the update by primary key selective SQL Map element and DAO method. If the table has a primary key as well as other fields, and the updateByPrimaryKey statement is allowed, then generate the element and method.- Specified by:
generateUpdateByPrimaryKeySelectivein interfaceRules- Returns:
- true if the element and method should be generated
-
generateUpdateByPrimaryKeyWithBLOBs
public boolean generateUpdateByPrimaryKeyWithBLOBs()Description copied from interface:RulesImplements the rule for generating the update by primary key with BLOBs SQL Map element and DAO method. If the table has a primary key as well as other BLOB fields, and the updateByPrimaryKey statement is allowed, then generate the element and method.- Specified by:
generateUpdateByPrimaryKeyWithBLOBsin interfaceRules- Returns:
- true if the element and method should be generated
-
generateUpdateByPrimaryKeyWithoutBLOBs
public boolean generateUpdateByPrimaryKeyWithoutBLOBs()Description copied from interface:RulesImplements the rule for generating the update by primary key without BLOBs SQL Map element and DAO method. If the table has a primary key as well as other non-BLOB fields, and the updateByPrimaryKey statement is allowed, then generate the element and method.- Specified by:
generateUpdateByPrimaryKeyWithoutBLOBsin interfaceRules- Returns:
- true if the element and method should be generated
-
getIntrospectedTable
- Specified by:
getIntrospectedTablein interfaceRules
-
generateBaseColumnList
public boolean generateBaseColumnList()Description copied from interface:RulesImplements the rule for generating the SQL base column list element. Generate the element if any of the select methods are enabled.- Specified by:
generateBaseColumnListin interfaceRules- Returns:
- true if the SQL base column list element should be generated
-
generateBlobColumnList
public boolean generateBlobColumnList()Description copied from interface:RulesImplements the rule for generating the SQL blob column list element. Generate the element if any of the select methods are enabled, and the table contains BLOB columns.- Specified by:
generateBlobColumnListin interfaceRules- Returns:
- true if the SQL blob column list element should be generated
-
generateJavaClient
public boolean generateJavaClient()Description copied from interface:RulesImplements the rule for generating a Java client. This rule is only active when a javaClientGenerator configuration has been specified, but the table is designated as "modelOnly". Do not generate the client if the table is designated as modelOnly.- Specified by:
generateJavaClientin interfaceRules- Returns:
- true if the Java client should be generated
-