Java Code Examples for org.mybatis.generator.api.IntrospectedTable#setExampleType()

The following examples show how to use org.mybatis.generator.api.IntrospectedTable#setExampleType() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RenameExampleClassPlugin.java    From mapper-generator-javafx with Apache License 2.0 5 votes vote down vote up
@Override
public void initialized(IntrospectedTable introspectedTable) {
    String oldType = introspectedTable.getExampleType();
    Matcher matcher = pattern.matcher(oldType);
    oldType = matcher.replaceAll(replaceString);

    introspectedTable.setExampleType(oldType);
}
 
Example 2
Source File: ExampleTargetPlugin.java    From mybatis-generator-plugin with Apache License 2.0 5 votes vote down vote up
/**
 * 初始化阶段
 * 具体执行顺序 http://www.mybatis.org/generator/reference/pluggingIn.html
 *
 * @param introspectedTable
 */
@Override
public void initialized(IntrospectedTable introspectedTable) {
    super.initialized(introspectedTable);
    String exampleType = introspectedTable.getExampleType();
    // 修改包名
    Context context = getContext();
    JavaModelGeneratorConfiguration configuration = context.getJavaModelGeneratorConfiguration();
    String targetPackage = configuration.getTargetPackage();
    String newExampleType = exampleType.replace(targetPackage, this.targetPackage);

    introspectedTable.setExampleType(newExampleType);

    logger.debug("itfsw(Example 目标包修改插件):修改"+introspectedTable.getExampleType()+"的包到"+this.targetPackage);
}
 
Example 3
Source File: IntrospectedTableTools.java    From mybatis-generator-plugin with Apache License 2.0 5 votes vote down vote up
/**
 * 设置DomainObjectName和MapperName
 * @param introspectedTable
 * @param context
 * @param domainObjectName
 */
public static void setDomainObjectName(IntrospectedTable introspectedTable, Context context, String domainObjectName) throws NoSuchFieldException, IllegalAccessException, NoSuchMethodException, InvocationTargetException {
    // 配置信息(没啥用)
    introspectedTable.getTableConfiguration().setDomainObjectName(domainObjectName);

    // FullyQualifiedTable修正
    Field domainObjectNameField = FullyQualifiedTable.class.getDeclaredField("domainObjectName");
    domainObjectNameField.setAccessible(true);
    domainObjectNameField.set(introspectedTable.getFullyQualifiedTable(), domainObjectName);

    // 重新修正introspectedTable属性信息
    Method calculateJavaClientAttributes = IntrospectedTable.class.getDeclaredMethod("calculateJavaClientAttributes");
    calculateJavaClientAttributes.setAccessible(true);
    calculateJavaClientAttributes.invoke(introspectedTable);

    Method calculateModelAttributes = IntrospectedTable.class.getDeclaredMethod("calculateModelAttributes");
    calculateModelAttributes.setAccessible(true);
    calculateModelAttributes.invoke(introspectedTable);

    Method calculateXmlAttributes = IntrospectedTable.class.getDeclaredMethod("calculateXmlAttributes");
    calculateXmlAttributes.setAccessible(true);
    calculateXmlAttributes.invoke(introspectedTable);

    // 注意!! 如果配置了ExampleTargetPlugin插件,要修正Example 位置
    PluginConfiguration configuration = PluginTools.getPluginConfiguration(context, ExampleTargetPlugin.class);
    if (configuration != null && configuration.getProperty(ExampleTargetPlugin.PRO_TARGET_PACKAGE) != null) {
        String exampleType = introspectedTable.getExampleType();
        // 修改包名
        JavaModelGeneratorConfiguration javaModelGeneratorConfiguration = context.getJavaModelGeneratorConfiguration();
        String targetPackage = javaModelGeneratorConfiguration.getTargetPackage();
        String newExampleType = exampleType.replace(targetPackage, configuration.getProperty(ExampleTargetPlugin.PRO_TARGET_PACKAGE));

        introspectedTable.setExampleType(newExampleType);
    }
}
 
Example 4
Source File: RenameExampleClassPlugin.java    From mybatis-generator-core-fix with Apache License 2.0 5 votes vote down vote up
@Override
public void initialized(IntrospectedTable introspectedTable) {
    String oldType = introspectedTable.getExampleType();
    Matcher matcher = pattern.matcher(oldType);
    oldType = matcher.replaceAll(replaceString);

    introspectedTable.setExampleType(oldType);
}
 
Example 5
Source File: RenameExampleClassPlugin.java    From mybatis-generator-plus with Apache License 2.0 5 votes vote down vote up
@Override
public void initialized(IntrospectedTable introspectedTable) {
    String oldType = introspectedTable.getExampleType();
    Matcher matcher = pattern.matcher(oldType);
    oldType = matcher.replaceAll(replaceString);

    introspectedTable.setExampleType(oldType);
}
 
Example 6
Source File: RenameExampleClassAndMethodsPlugin.java    From mybatis-generator-plugins with Apache License 2.0 5 votes vote down vote up
@Override
public void initialized(IntrospectedTable introspectedTable) {
	String oldType = introspectedTable.getExampleType();
	Matcher matcher = classMethodPattern.matcher(oldType);
	oldType = matcher.replaceAll(classMethodReplaceString);

	introspectedTable.setExampleType(oldType);
}
 
Example 7
Source File: CreateSubPackagePlugin.java    From mybatis-generator-plugins with Apache License 2.0 5 votes vote down vote up
@Override
public void initialized(IntrospectedTable introspectedTable) {
	introspectedTable.setBaseRecordType(modelProperties.setTypes(introspectedTable.getBaseRecordType()));
	introspectedTable.setMyBatis3JavaMapperType(mapperProperties.setTypes(introspectedTable
			.getMyBatis3JavaMapperType()));
	introspectedTable.setExampleType(exampleProperties.setTypes(introspectedTable.getExampleType()));
}