Search in sources :

Example 46 with FullyQualifiedJavaType

use of org.mybatis.generator.api.dom.java.FullyQualifiedJavaType in project generator by mybatis.

the class SupersGenerator method getSuperInterface.

private Interface getSuperInterface() {
    FullyQualifiedJavaType fqjt = new FullyQualifiedJavaType(BASE_PACKAGE + ".sub.SuperInterface");
    Interface ifc = new Interface(fqjt);
    ifc.setVisibility(JavaVisibility.PUBLIC);
    return ifc;
}
Also used : FullyQualifiedJavaType(org.mybatis.generator.api.dom.java.FullyQualifiedJavaType) Interface(org.mybatis.generator.api.dom.java.Interface)

Example 47 with FullyQualifiedJavaType

use of org.mybatis.generator.api.dom.java.FullyQualifiedJavaType in project generator by mybatis.

the class SupersGenerator method getBaseClass.

private TopLevelClass getBaseClass() {
    FullyQualifiedJavaType fqjt = new FullyQualifiedJavaType(BASE_PACKAGE + ".BaseClass");
    TopLevelClass tlc = new TopLevelClass(fqjt);
    tlc.setVisibility(JavaVisibility.PUBLIC);
    return tlc;
}
Also used : FullyQualifiedJavaType(org.mybatis.generator.api.dom.java.FullyQualifiedJavaType) TopLevelClass(org.mybatis.generator.api.dom.java.TopLevelClass)

Example 48 with FullyQualifiedJavaType

use of org.mybatis.generator.api.dom.java.FullyQualifiedJavaType in project generator by mybatis.

the class Test1Generator method generate.

public List<CompilationUnit> generate() {
    FullyQualifiedJavaType cls = new FullyQualifiedJavaType(BASE_PACKAGE + ".SomeClass");
    List<CompilationUnit> answer = new ArrayList<CompilationUnit>();
    TopLevelClass tlcMain = generateFieldTypeMain();
    TopLevelClass tlcSub1 = generateFieldTypeSub1();
    TopLevelClass tlcTcSub1 = generateTestClassSub1();
    TopLevelClass tlcSub2 = generateFieldTypeSub2();
    answer.add(tlcMain);
    answer.add(tlcSub1);
    answer.add(tlcTcSub1);
    answer.add(tlcSub2);
    TopLevelClass topLvlClass = new TopLevelClass(cls);
    topLvlClass.setVisibility(JavaVisibility.PUBLIC);
    topLvlClass.addImportedType(tlcTcSub1.getType());
    Field field = new Field("main", tlcMain.getType());
    field.setVisibility(JavaVisibility.PRIVATE);
    topLvlClass.addField(field);
    field = new Field("tcSub1", tlcTcSub1.getType());
    field.setVisibility(JavaVisibility.PRIVATE);
    topLvlClass.addField(field);
    field = new Field("sub1", tlcSub1.getType());
    field.setVisibility(JavaVisibility.PRIVATE);
    topLvlClass.addField(field);
    field = new Field("sub2", tlcSub2.getType());
    field.setVisibility(JavaVisibility.PRIVATE);
    topLvlClass.addField(field);
    Method m = new Method();
    m.setVisibility(JavaVisibility.PUBLIC);
    m.setName("executeMain");
    m.addBodyLine("main.mainMethod();");
    topLvlClass.addMethod(m);
    m = new Method();
    m.setVisibility(JavaVisibility.PUBLIC);
    m.setName("setMain");
    m.addParameter(new Parameter(tlcMain.getType(), "main"));
    m.addBodyLine("this.main = main;");
    topLvlClass.addMethod(m);
    m = new Method();
    m.setVisibility(JavaVisibility.PUBLIC);
    m.setName("getMain");
    m.setReturnType(tlcMain.getType());
    m.addBodyLine("return main;");
    topLvlClass.addMethod(m);
    m = new Method();
    m.setVisibility(JavaVisibility.PUBLIC);
    m.setName("executeSub1");
    m.addBodyLine("sub1.sub1Method();");
    topLvlClass.addMethod(m);
    m = new Method();
    m.setVisibility(JavaVisibility.PUBLIC);
    m.setName("setSub1");
    m.addParameter(new Parameter(tlcSub1.getType(), "sub1"));
    m.addBodyLine("this.sub1 = sub1;");
    topLvlClass.addMethod(m);
    m = new Method();
    m.setVisibility(JavaVisibility.PUBLIC);
    m.setName("getSub1");
    m.setReturnType(tlcSub1.getType());
    m.addBodyLine("return sub1;");
    topLvlClass.addMethod(m);
    m = new Method();
    m.setVisibility(JavaVisibility.PUBLIC);
    m.setName("executeSub2");
    m.addBodyLine("sub2.sub2Method();");
    topLvlClass.addMethod(m);
    m = new Method();
    m.setVisibility(JavaVisibility.PUBLIC);
    m.setName("setSub2");
    m.addParameter(new Parameter(tlcSub2.getType(), "sub2"));
    m.addBodyLine("this.sub2 = sub2;");
    topLvlClass.addMethod(m);
    m = new Method();
    m.setVisibility(JavaVisibility.PUBLIC);
    m.setName("getSub2");
    m.setReturnType(tlcSub2.getType());
    m.addBodyLine("return sub2;");
    topLvlClass.addMethod(m);
    answer.add(topLvlClass);
    return answer;
}
Also used : CompilationUnit(org.mybatis.generator.api.dom.java.CompilationUnit) Field(org.mybatis.generator.api.dom.java.Field) FullyQualifiedJavaType(org.mybatis.generator.api.dom.java.FullyQualifiedJavaType) TopLevelClass(org.mybatis.generator.api.dom.java.TopLevelClass) ArrayList(java.util.ArrayList) Parameter(org.mybatis.generator.api.dom.java.Parameter) Method(org.mybatis.generator.api.dom.java.Method)

Example 49 with FullyQualifiedJavaType

use of org.mybatis.generator.api.dom.java.FullyQualifiedJavaType in project generator by mybatis.

the class SimpleInterfaceGenerator method generateClass.

private TopLevelClass generateClass(Interface interfaze) {
    FullyQualifiedJavaType fqjt = new FullyQualifiedJavaType(BASE_PACKAGE + "SimpleClass");
    TopLevelClass tlc = new TopLevelClass(fqjt);
    tlc.setVisibility(JavaVisibility.PUBLIC);
    tlc.addSuperInterface(interfaze.getType());
    tlc.addImportedType(interfaze.getType());
    return tlc;
}
Also used : FullyQualifiedJavaType(org.mybatis.generator.api.dom.java.FullyQualifiedJavaType) TopLevelClass(org.mybatis.generator.api.dom.java.TopLevelClass)

Example 50 with FullyQualifiedJavaType

use of org.mybatis.generator.api.dom.java.FullyQualifiedJavaType in project generator by mybatis.

the class SerializablePlugin method makeSerializable.

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);
        //$NON-NLS-1$
        field.setInitializationString("1L");
        //$NON-NLS-1$
        field.setName("serialVersionUID");
        field.setStatic(true);
        //$NON-NLS-1$
        field.setType(new FullyQualifiedJavaType("long"));
        field.setVisibility(JavaVisibility.PRIVATE);
        context.getCommentGenerator().addFieldComment(field, introspectedTable);
        topLevelClass.addField(field);
    }
}
Also used : Field(org.mybatis.generator.api.dom.java.Field) FullyQualifiedJavaType(org.mybatis.generator.api.dom.java.FullyQualifiedJavaType)

Aggregations

FullyQualifiedJavaType (org.mybatis.generator.api.dom.java.FullyQualifiedJavaType)163 Method (org.mybatis.generator.api.dom.java.Method)97 Parameter (org.mybatis.generator.api.dom.java.Parameter)54 TreeSet (java.util.TreeSet)53 IntrospectedColumn (org.mybatis.generator.api.IntrospectedColumn)32 Test (org.junit.Test)24 ArrayList (java.util.ArrayList)19 Field (org.mybatis.generator.api.dom.java.Field)19 TopLevelClass (org.mybatis.generator.api.dom.java.TopLevelClass)19 Messages.getString (org.mybatis.generator.internal.util.messages.Messages.getString)14 CommentGenerator (org.mybatis.generator.api.CommentGenerator)11 CompilationUnit (org.mybatis.generator.api.dom.java.CompilationUnit)11 Interface (org.mybatis.generator.api.dom.java.Interface)10 FullyQualifiedTable (org.mybatis.generator.api.FullyQualifiedTable)7 GeneratedKey (org.mybatis.generator.config.GeneratedKey)7 Plugin (org.mybatis.generator.api.Plugin)5 Attribute (org.mybatis.generator.api.dom.xml.Attribute)5 TextElement (org.mybatis.generator.api.dom.xml.TextElement)5 XmlElement (org.mybatis.generator.api.dom.xml.XmlElement)5 JavaBeansUtil.getJavaBeansField (org.mybatis.generator.internal.util.JavaBeansUtil.getJavaBeansField)5