Java Code Examples for org.mybatis.generator.api.dom.java.TopLevelClass#addSuperInterface()

The following examples show how to use org.mybatis.generator.api.dom.java.TopLevelClass#addSuperInterface() . 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: SerializablePlugin.java    From feiqu-opensource with Apache License 2.0 6 votes vote down vote up
protected void makeSerializable(TopLevelClass topLevelClass, IntrospectedTable introspectedTable) {
    if(this.addGWTInterface) {
        topLevelClass.addImportedType(this.gwtSerializable);
        topLevelClass.addSuperInterface(this.gwtSerializable);
    }

    if(!this.suppressJavaInterface) {
        topLevelClass.addImportedType(this.serializable);
        topLevelClass.addSuperInterface(this.serializable);
        Field field = new Field();
        field.setFinal(true);
        field.setInitializationString("1L");
        field.setName("serialVersionUID");
        field.setStatic(true);
        field.setType(new FullyQualifiedJavaType("long"));
        field.setVisibility(JavaVisibility.PRIVATE);
        this.context.getCommentGenerator().addFieldComment(field, introspectedTable);
        topLevelClass.addField(field);
    }

}
 
Example 2
Source File: HySwaggerMapperPlugin.java    From jvue-admin with MIT License 6 votes vote down vote up
private void impSerializableInterface(TopLevelClass topLevelClass, IntrospectedTable introspectedTable) {
	if (this.implementSerializableInteface) {
		String serializable = "java.io.Serializable";
		topLevelClass.addImportedType(serializable);
		FullyQualifiedJavaType superInterface = new FullyQualifiedJavaType(serializable);
		topLevelClass.addSuperInterface(superInterface);

		Field serialVersionUID = new Field("serialVersionUID", new FullyQualifiedJavaType("long"));
		serialVersionUID.setVisibility(JavaVisibility.PRIVATE);
		serialVersionUID.setStatic(true);
		serialVersionUID.setFinal(true);

		serialVersionUID.setInitializationString("1L");
		topLevelClass.addField(serialVersionUID);
	}
}
 
Example 3
Source File: CustomSettingsPlugin.java    From BlogManagePlatform with Apache License 2.0 6 votes vote down vote up
/**
 * 配置序列化
 * @author Frodez
 * @date 2019-01-13
 */
private void makeSerializable(TopLevelClass klass, IntrospectedTable table) {
	klass.addImportedType(new FullyQualifiedJavaType("java.io.Serializable"));
	klass.addSuperInterface(new FullyQualifiedJavaType("java.io.Serializable"));
	Field field = new Field("serialVersionUID", new FullyQualifiedJavaType("long"));
	field.setFinal(true);
	field.setInitializationString("1L");
	field.addJavaDocLine("");
	field.setStatic(true);
	field.setVisibility(JavaVisibility.PRIVATE);
	if (table.getTargetRuntime() == TargetRuntime.MYBATIS3_DSQL) {
		context.getCommentGenerator().addFieldAnnotation(field, table, klass.getImportedTypes());
	} else {
		context.getCommentGenerator().addFieldComment(field, table);
	}
	klass.getFields().add(0, field);
}
 
Example 4
Source File: SerializablePlugin.java    From mybatis-generator-core-fix with Apache License 2.0 6 votes vote down vote up
protected void makeSerializable(TopLevelClass topLevelClass,
        IntrospectedTable introspectedTable) {
    if (addGWTInterface) {
        topLevelClass.addImportedType(gwtSerializable);
        topLevelClass.addSuperInterface(gwtSerializable);
    }
    
    if (!suppressJavaInterface) {
        topLevelClass.addImportedType(serializable);
        topLevelClass.addSuperInterface(serializable);

        Field field = new Field();
        field.setFinal(true);
        field.setInitializationString("1L"); //$NON-NLS-1$
        field.setName("serialVersionUID"); //$NON-NLS-1$
        field.setStatic(true);
        field.setType(new FullyQualifiedJavaType("long")); //$NON-NLS-1$
        field.setVisibility(JavaVisibility.PRIVATE);
        context.getCommentGenerator().addFieldComment(field, introspectedTable);

        topLevelClass.addField(field);
    }
}
 
Example 5
Source File: SerializablePlugin.java    From mybatis-generator-plus with Apache License 2.0 6 votes vote down vote up
protected void makeSerializable(TopLevelClass topLevelClass,
        IntrospectedTable introspectedTable) {
    if (addGWTInterface) {
        topLevelClass.addImportedType(gwtSerializable);
        topLevelClass.addSuperInterface(gwtSerializable);
    }
    
    if (!suppressJavaInterface) {
        topLevelClass.addImportedType(serializable);
        topLevelClass.addSuperInterface(serializable);

        Field field = new Field();
        field.setFinal(true);
        field.setInitializationString("1L"); //$NON-NLS-1$
        field.setName("serialVersionUID"); //$NON-NLS-1$
        field.setStatic(true);
        field.setType(new FullyQualifiedJavaType("long")); //$NON-NLS-1$
        field.setVisibility(JavaVisibility.PRIVATE);
        context.getCommentGenerator().addFieldComment(field, introspectedTable);

        topLevelClass.addField(field);
    }
}
 
Example 6
Source File: CustomSerializablePlugin.java    From mybatis-generator-plus with Apache License 2.0 6 votes vote down vote up
protected void makeSerializable(TopLevelClass topLevelClass, IntrospectedTable introspectedTable) {
    if (addGWTInterface) {
        topLevelClass.addImportedType(gwtSerializable);
        topLevelClass.addSuperInterface(gwtSerializable);
    }

    if (!suppressJavaInterface) {
        topLevelClass.addImportedType(serializable);
        topLevelClass.addSuperInterface(serializable);

        Field field = new Field();
        field.setFinal(true);
        field.setInitializationString("1L"); //$NON-NLS-1$
        field.setName("serialVersionUID"); //$NON-NLS-1$
        field.setStatic(true);
        field.setType(new FullyQualifiedJavaType("long")); //$NON-NLS-1$
        field.setVisibility(JavaVisibility.PRIVATE);
        context.getCommentGenerator().addFieldComment(field, introspectedTable);

        topLevelClass.addField(field);
    }
}
 
Example 7
Source File: SerializablePlugin.java    From mapper-generator-javafx with Apache License 2.0 5 votes vote down vote up
protected void makeSerializable(TopLevelClass topLevelClass, IntrospectedTable introspectedTable) {
    final boolean serializable = Boolean.parseBoolean(introspectedTable.getTableConfigurationProperty("jdkSerializable"));
    if (!serializable) {
        return;
    }

    if (addGWTInterface) {
        topLevelClass.addImportedType(gwtSerializable);
        topLevelClass.addSuperInterface(gwtSerializable);
    }

    if (!suppressJavaInterface) {
        topLevelClass.addImportedType(this.serializable);
        topLevelClass.addSuperInterface(this.serializable);

        Field field = new Field("serialVersionUID", new FullyQualifiedJavaType("long"));
        field.setFinal(true);
        field.setInitializationString("1L");
        field.setStatic(true);
        field.setVisibility(JavaVisibility.PRIVATE);

        if (introspectedTable.getTargetRuntime() == TargetRuntime.MYBATIS3_DSQL) {
            context.getCommentGenerator().addFieldAnnotation(field, introspectedTable, topLevelClass.getImportedTypes());
        } else {
            context.getCommentGenerator().addFieldComment(field, introspectedTable);
        }

        topLevelClass.addField(field);
    }
}
 
Example 8
Source File: POJOExtendsPlugin.java    From S-mall-ssm with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean modelBaseRecordClassGenerated(TopLevelClass topLevelClass, IntrospectedTable introspectedTable) {

    FullyQualifiedJavaType mapperType = new FullyQualifiedJavaType(introspectedTable.getMyBatis3JavaMapperType());
    // import接口
    topLevelClass.addImportedType(mapperType);
    topLevelClass.addSuperInterface(new FullyQualifiedJavaType(
            POJO + "<" + mapperType.getShortName() + ">"
    ));
    return true;
}
 
Example 9
Source File: ExampleExtendsPlugin.java    From S-mall-ssm with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean modelExampleClassGenerated(TopLevelClass topLevelClass, IntrospectedTable introspectedTable) {

    // import接口
    topLevelClass.addImportedType(example);
    topLevelClass.addSuperInterface(new FullyQualifiedJavaType(
            example
    ));
    return true;
}
 
Example 10
Source File: DAOGenerator.java    From mybatis-generator-core-fix with Apache License 2.0 5 votes vote down vote up
protected TopLevelClass getTopLevelClassShell() {
    FullyQualifiedJavaType interfaceType = new FullyQualifiedJavaType(
            introspectedTable.getDAOInterfaceType());
    FullyQualifiedJavaType implementationType = new FullyQualifiedJavaType(
            introspectedTable.getDAOImplementationType());

    CommentGenerator commentGenerator = context.getCommentGenerator();

    TopLevelClass answer = new TopLevelClass(implementationType);
    answer.setVisibility(JavaVisibility.PUBLIC);
    answer.setSuperClass(daoTemplate.getSuperClass());
    answer.addImportedType(daoTemplate.getSuperClass());
    answer.addSuperInterface(interfaceType);
    answer.addImportedType(interfaceType);

    for (FullyQualifiedJavaType fqjt : daoTemplate
            .getImplementationImports()) {
        answer.addImportedType(fqjt);
    }

    commentGenerator.addJavaFileComment(answer);

    // add constructor from the template
    answer.addMethod(daoTemplate.getConstructorClone(commentGenerator,
            implementationType, introspectedTable));

    // add any fields from the template
    for (Field field : daoTemplate.getFieldClones(commentGenerator,
            introspectedTable)) {
        answer.addField(field);
    }

    // add any methods from the template
    for (Method method : daoTemplate.getMethodClones(commentGenerator,
            introspectedTable)) {
        answer.addMethod(method);
    }

    return answer;
}
 
Example 11
Source File: DAOGenerator.java    From mybatis-generator-plus with Apache License 2.0 5 votes vote down vote up
protected TopLevelClass getTopLevelClassShell() {
    FullyQualifiedJavaType interfaceType = new FullyQualifiedJavaType(
            introspectedTable.getDAOInterfaceType());
    FullyQualifiedJavaType implementationType = new FullyQualifiedJavaType(
            introspectedTable.getDAOImplementationType());

    CommentGenerator commentGenerator = context.getCommentGenerator();

    TopLevelClass answer = new TopLevelClass(implementationType);
    answer.setVisibility(JavaVisibility.PUBLIC);
    answer.setSuperClass(daoTemplate.getSuperClass());
    answer.addImportedType(daoTemplate.getSuperClass());
    answer.addSuperInterface(interfaceType);
    answer.addImportedType(interfaceType);

    for (FullyQualifiedJavaType fqjt : daoTemplate
            .getImplementationImports()) {
        answer.addImportedType(fqjt);
    }

    commentGenerator.addJavaFileComment(answer);

    // add constructor from the template
    answer.addMethod(daoTemplate.getConstructorClone(commentGenerator,
            implementationType, introspectedTable));

    // add any fields from the template
    for (Field field : daoTemplate.getFieldClones(commentGenerator,
            introspectedTable)) {
        answer.addField(field);
    }

    // add any methods from the template
    for (Method method : daoTemplate.getMethodClones(commentGenerator,
            introspectedTable)) {
        answer.addMethod(method);
    }

    return answer;
}
 
Example 12
Source File: AlterModelPlugin.java    From mybatis-generator-plugins with Apache License 2.0 5 votes vote down vote up
@Override
public boolean modelBaseRecordClassGenerated(TopLevelClass topLevelClass, IntrospectedTable introspectedTable) {
	if (tableMatches(introspectedTable)) {
		for (String theInterface : addInterfaces) {
			FullyQualifiedJavaType type = new FullyQualifiedJavaType(theInterface);
			topLevelClass.addImportedType(type);
			topLevelClass.addSuperInterface(type);
		}
	}

	return true;
}