本文整理汇总了Java中org.mybatis.generator.api.CommentGenerator类的典型用法代码示例。如果您正苦于以下问题:Java CommentGenerator类的具体用法?Java CommentGenerator怎么用?Java CommentGenerator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CommentGenerator类属于org.mybatis.generator.api包,在下文中一共展示了CommentGenerator类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getConstructorClone
import org.mybatis.generator.api.CommentGenerator; //导入依赖的package包/类
/**
* Gets the constructor clone.
*
* @param commentGenerator
* the comment generator
* @param type
* the type
* @param introspectedTable
* the introspected table
* @return the constructor clone
*/
public final Method getConstructorClone(CommentGenerator commentGenerator,
FullyQualifiedJavaType type, IntrospectedTable introspectedTable) {
configure();
Method answer = new Method();
answer.setConstructor(true);
answer.setName(type.getShortName());
answer.setVisibility(constructorTemplate.getVisibility());
for (Parameter parm : constructorTemplate.getParameters()) {
answer.addParameter(parm);
}
for (String bodyLine : constructorTemplate.getBodyLines()) {
answer.addBodyLine(bodyLine);
}
for (FullyQualifiedJavaType fqjt : constructorTemplate.getExceptions()) {
answer.addException(fqjt);
}
commentGenerator.addGeneralMethodComment(answer, introspectedTable);
return answer;
}
示例2: getFieldClones
import org.mybatis.generator.api.CommentGenerator; //导入依赖的package包/类
/**
* Gets the field clones.
*
* @param commentGenerator
* the comment generator
* @param introspectedTable
* the introspected table
* @return the field clones
*/
public final List<Field> getFieldClones(CommentGenerator commentGenerator,
IntrospectedTable introspectedTable) {
configure();
List<Field> answer = new ArrayList<Field>();
for (Field oldField : fields) {
Field field = new Field();
field.setInitializationString(oldField.getInitializationString());
field.setFinal(oldField.isFinal());
field.setStatic(oldField.isStatic());
field.setName(oldField.getName());
field.setType(oldField.getType());
field.setVisibility(oldField.getVisibility());
commentGenerator.addFieldComment(field, introspectedTable);
answer.add(field);
}
return answer;
}
示例3: testThatFilesAreTheSameAfterMerge
import org.mybatis.generator.api.CommentGenerator; //导入依赖的package包/类
@Test
public void testThatFilesAreTheSameAfterMerge() throws Exception {
DefaultXmlFormatter xmlFormatter = new DefaultXmlFormatter();
Properties p = new Properties();
p.setProperty(PropertyRegistry.COMMENT_GENERATOR_SUPPRESS_DATE, "true");
CommentGenerator commentGenerator = new DefaultCommentGenerator();
commentGenerator.addConfigurationProperties(p);
Document document = new Document(XmlConstants.MYBATIS3_MAPPER_PUBLIC_ID,
XmlConstants.MYBATIS3_MAPPER_SYSTEM_ID);
document.setRootElement(getSqlMapElement(commentGenerator));
GeneratedXmlFile generatedFile1 = new GeneratedXmlFile(document, "TestMapper.xml", "org.mybatis.test", "src",
true, xmlFormatter);
InputSource is1 = new InputSource(new StringReader(generatedFile1.getFormattedContent()));
GeneratedXmlFile generatedFile2 = new GeneratedXmlFile(document, "TestMapper.xml", "org.mybatis.test", "src",
true, xmlFormatter);
InputSource is2 = new InputSource(new StringReader(generatedFile2.getFormattedContent()));
String mergedSource = XmlFileMergerJaxp.getMergedSource(is1, is2, "TestMapper.xml");
assertEquals(generatedFile1.getFormattedContent(), mergedSource);
}
示例4: getCommentGenerator
import org.mybatis.generator.api.CommentGenerator; //导入依赖的package包/类
/**
* Gets the comment generator.
*
* @return the comment generator
*/
public CommentGenerator getCommentGenerator() {
if (commentGenerator == null) {
commentGenerator = ObjectFactory.createCommentGenerator(this);
}
return commentGenerator;
}
示例5: getMethodClones
import org.mybatis.generator.api.CommentGenerator; //导入依赖的package包/类
/**
* Gets the method clones.
*
* @param commentGenerator
* the comment generator
* @param introspectedTable
* the introspected table
* @return the method clones
*/
public final List<Method> getMethodClones(
CommentGenerator commentGenerator,
IntrospectedTable introspectedTable) {
configure();
List<Method> answer = new ArrayList<Method>();
for (Method oldMethod : methods) {
Method method = new Method();
for (String bodyLine : oldMethod.getBodyLines()) {
method.addBodyLine(bodyLine);
}
for (FullyQualifiedJavaType fqjt : oldMethod.getExceptions()) {
method.addException(fqjt);
}
for (Parameter parm : oldMethod.getParameters()) {
method.addParameter(parm);
}
method.setConstructor(oldMethod.isConstructor());
method.setFinal(oldMethod.isFinal());
method.setStatic(oldMethod.isStatic());
method.setName(oldMethod.getName());
method.setReturnType(oldMethod.getReturnType());
method.setVisibility(oldMethod.getVisibility());
commentGenerator.addGeneralMethodComment(method, introspectedTable);
answer.add(method);
}
return answer;
}
示例6: getTopLevelClassShell
import org.mybatis.generator.api.CommentGenerator; //导入依赖的package包/类
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;
}
示例7: getCompilationUnits
import org.mybatis.generator.api.CommentGenerator; //导入依赖的package包/类
@Override
public List<CompilationUnit> getCompilationUnits() {
progressCallback.startTask(getString("Progress.18", //$NON-NLS-1$
introspectedTable.getFullyQualifiedTable().toString()));
CommentGenerator commentGenerator = context.getCommentGenerator();
FullyQualifiedJavaType type = new FullyQualifiedJavaType(
introspectedTable.getMyBatis3SqlProviderType());
TopLevelClass topLevelClass = new TopLevelClass(type);
topLevelClass.setVisibility(JavaVisibility.PUBLIC);
commentGenerator.addJavaFileComment(topLevelClass);
boolean addApplyWhereMethod = false;
addApplyWhereMethod |= addCountByExampleMethod(topLevelClass);
addApplyWhereMethod |= addDeleteByExampleMethod(topLevelClass);
addInsertSelectiveMethod(topLevelClass);
addApplyWhereMethod |= addSelectByExampleWithBLOBsMethod(topLevelClass);
addApplyWhereMethod |= addSelectByExampleWithoutBLOBsMethod(topLevelClass);
addApplyWhereMethod |= addUpdateByExampleSelectiveMethod(topLevelClass);
addApplyWhereMethod |= addUpdateByExampleWithBLOBsMethod(topLevelClass);
addApplyWhereMethod |= addUpdateByExampleWithoutBLOBsMethod(topLevelClass);
addUpdateByPrimaryKeySelectiveMethod(topLevelClass);
if (addApplyWhereMethod) {
addApplyWhereMethod(topLevelClass);
}
List<CompilationUnit> answer = new ArrayList<CompilationUnit>();
if (topLevelClass.getMethods().size() > 0 &&
context.getPlugins().providerGenerated(topLevelClass, introspectedTable)) {
answer.add(topLevelClass);
}
return answer;
}
示例8: getSqlMapElement
import org.mybatis.generator.api.CommentGenerator; //导入依赖的package包/类
private XmlElement getSqlMapElement(CommentGenerator commentGenerator) {
XmlElement answer = new XmlElement("mapper");
String namespace = "org.mybatis.test.TestMapper";
answer.addAttribute(new Attribute("namespace", namespace));
commentGenerator.addRootComment(answer);
addInsertElement(commentGenerator, answer);
addCdataNode1(commentGenerator, answer);
addCdataNode2(commentGenerator, answer);
return answer;
}
示例9: addCdataNode1
import org.mybatis.generator.api.CommentGenerator; //导入依赖的package包/类
private void addCdataNode1(CommentGenerator commentGenerator, XmlElement parentElement) {
XmlElement answer = new XmlElement("select");
answer.addAttribute(new Attribute("id", "selectWithCdata1"));
commentGenerator.addComment(answer);
answer.addElement(new TextElement("<![CDATA["));
answer.addElement(new TextElement("select foo from bar where foo < 22"));
answer.addElement(new TextElement("]]>"));
parentElement.addElement(answer);
}
示例10: addCdataNode2
import org.mybatis.generator.api.CommentGenerator; //导入依赖的package包/类
private void addCdataNode2(CommentGenerator commentGenerator, XmlElement parentElement) {
XmlElement answer = new XmlElement("select");
answer.addAttribute(new Attribute("id", "selectWithCdata2"));
commentGenerator.addComment(answer);
answer.addElement(new TextElement("select foo from bar where foo <![CDATA[ < ]]> 22"));
parentElement.addElement(answer);
}
示例11: addSerialVersionUID
import org.mybatis.generator.api.CommentGenerator; //导入依赖的package包/类
private void addSerialVersionUID(TopLevelClass topLevelClass, IntrospectedTable introspectedTable) {
CommentGenerator commentGenerator = context.getCommentGenerator();
Field field = new Field();
field.setVisibility(JavaVisibility.PRIVATE);
field.setType(new FullyQualifiedJavaType("Long"));
field.setStatic(true);
field.setFinal(true);
field.setName("serialVersionUID");
field.setInitializationString("1L");
commentGenerator.addFieldComment(field, introspectedTable);
topLevelClass.addField(field);
}