本文整理汇总了Java中org.mybatis.generator.api.dom.java.PrimitiveTypeWrapper类的典型用法代码示例。如果您正苦于以下问题:Java PrimitiveTypeWrapper类的具体用法?Java PrimitiveTypeWrapper怎么用?Java PrimitiveTypeWrapper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PrimitiveTypeWrapper类属于org.mybatis.generator.api.dom.java包,在下文中一共展示了PrimitiveTypeWrapper类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addLimit
import org.mybatis.generator.api.dom.java.PrimitiveTypeWrapper; //导入依赖的package包/类
private void addLimit(TopLevelClass topLevelClass, IntrospectedTable introspectedTable, String name)
{
CommentGenerator commentGenerator = context.getCommentGenerator();
Field field = new Field();
field.setVisibility(JavaVisibility.PROTECTED);
// field.setType(FullyQualifiedJavaType.getIntInstance());
field.setType(PrimitiveTypeWrapper.getIntegerInstance());
field.setName(name);
// field.setInitializationString("-1");
commentGenerator.addFieldComment(field, introspectedTable);
topLevelClass.addField(field);
char c = name.charAt(0);
String camel = Character.toUpperCase(c) + name.substring(1);
Method method = new Method();
method.setVisibility(JavaVisibility.PUBLIC);
method.setName("set" + camel);
method.addParameter(new Parameter(PrimitiveTypeWrapper.getIntegerInstance(), name));
method.addBodyLine("this." + name + "=" + name + ";");
commentGenerator.addGeneralMethodComment(method, introspectedTable);
topLevelClass.addMethod(method);
method = new Method();
method.setVisibility(JavaVisibility.PUBLIC);
method.setReturnType(PrimitiveTypeWrapper.getIntegerInstance());
method.setName("get" + camel);
method.addBodyLine("return " + name + ";");
commentGenerator.addGeneralMethodComment(method, introspectedTable);
topLevelClass.addMethod(method);
}
示例2: modelExampleClassGenerated
import org.mybatis.generator.api.dom.java.PrimitiveTypeWrapper; //导入依赖的package包/类
/**
* 在查询条件类中添加offset与limitCount字段
*/
@Override
public boolean modelExampleClassGenerated(TopLevelClass topLevelClass, IntrospectedTable introspectedTable) {
Field offsetField = new Field("offset", PrimitiveTypeWrapper.getIntegerInstance());
offsetField.setInitializationString("-1");
offsetField.setVisibility(JavaVisibility.PROTECTED);
addField(topLevelClass, introspectedTable, offsetField);
Field limitCountField = new Field("limitCount", PrimitiveTypeWrapper.getIntegerInstance());
limitCountField.setInitializationString("-1");
limitCountField.setVisibility(JavaVisibility.PROTECTED);
addField(topLevelClass, introspectedTable, limitCountField);
return super.modelExampleClassGenerated(topLevelClass, introspectedTable);
}
示例3: addImplementationElements
import org.mybatis.generator.api.dom.java.PrimitiveTypeWrapper; //导入依赖的package包/类
@Override
public void addImplementationElements(TopLevelClass topLevelClass) {
Set<FullyQualifiedJavaType> importedTypes = new TreeSet<FullyQualifiedJavaType>();
Method method = getMethodShell(importedTypes);
FullyQualifiedJavaType returnType = method.getReturnType();
StringBuilder sb = new StringBuilder();
if (returnType != null) {
sb.append("Object newKey = "); //$NON-NLS-1$
}
sb.append(daoTemplate.getInsertMethod(introspectedTable
.getIbatis2SqlMapNamespace(), introspectedTable
.getInsertStatementId(), "record")); //$NON-NLS-1$
method.addBodyLine(sb.toString());
if (returnType != null) {
if ("Object".equals(returnType.getShortName())) { //$NON-NLS-1$
// no need to cast if the return type is Object
method.addBodyLine("return newKey;"); //$NON-NLS-1$
} else {
sb.setLength(0);
if (returnType.isPrimitive()) {
PrimitiveTypeWrapper ptw = returnType
.getPrimitiveTypeWrapper();
sb.append("return (("); //$NON-NLS-1$
sb.append(ptw.getShortName());
sb.append(") newKey"); //$NON-NLS-1$
sb.append(")."); //$NON-NLS-1$
sb.append(ptw.getToPrimitiveMethod());
sb.append(';');
} else {
sb.append("return ("); //$NON-NLS-1$
sb.append(returnType.getShortName());
sb.append(") newKey;"); //$NON-NLS-1$
}
method.addBodyLine(sb.toString());
}
}
if (context.getPlugins().clientInsertMethodGenerated(method,
topLevelClass, introspectedTable)) {
topLevelClass.addImportedTypes(importedTypes);
topLevelClass.addMethod(method);
}
}
示例4: addImplementationElements
import org.mybatis.generator.api.dom.java.PrimitiveTypeWrapper; //导入依赖的package包/类
@Override
public void addImplementationElements(TopLevelClass topLevelClass) {
Set<FullyQualifiedJavaType> importedTypes = new TreeSet<FullyQualifiedJavaType>();
Method method = getMethodShell(importedTypes);
FullyQualifiedJavaType returnType = method.getReturnType();
StringBuilder sb = new StringBuilder();
if (returnType != null) {
sb.append("Object newKey = "); //$NON-NLS-1$
}
sb.append(daoTemplate.getInsertMethod(introspectedTable
.getIbatis2SqlMapNamespace(), introspectedTable
.getInsertSelectiveStatementId(), "record")); //$NON-NLS-1$
method.addBodyLine(sb.toString());
if (returnType != null) {
if ("Object".equals(returnType.getShortName())) { //$NON-NLS-1$
// no need to cast if the return type is Object
method.addBodyLine("return newKey;"); //$NON-NLS-1$
} else {
sb.setLength(0);
if (returnType.isPrimitive()) {
PrimitiveTypeWrapper ptw = returnType
.getPrimitiveTypeWrapper();
sb.append("return (("); //$NON-NLS-1$
sb.append(ptw.getShortName());
sb.append(") newKey"); //$NON-NLS-1$
sb.append(")."); //$NON-NLS-1$
sb.append(ptw.getToPrimitiveMethod());
sb.append(';');
} else {
sb.append("return ("); //$NON-NLS-1$
sb.append(returnType.getShortName());
sb.append(") newKey;"); //$NON-NLS-1$
}
method.addBodyLine(sb.toString());
}
}
if (context.getPlugins().clientInsertSelectiveMethodGenerated(
method, topLevelClass, introspectedTable)) {
topLevelClass.addImportedTypes(importedTypes);
topLevelClass.addMethod(method);
}
}
示例5: addImplementationElements
import org.mybatis.generator.api.dom.java.PrimitiveTypeWrapper; //导入依赖的package包/类
@Override
public void addImplementationElements(TopLevelClass topLevelClass) {
Set<FullyQualifiedJavaType> importedTypes = new TreeSet<FullyQualifiedJavaType>();
Method method = getMethodShell(importedTypes);
if (generateForJava5) {
method.addAnnotation("@Override"); //$NON-NLS-1$
}
FullyQualifiedJavaType returnType = method.getReturnType();
StringBuilder sb = new StringBuilder();
if (returnType != null) {
sb.append("Object newKey = "); //$NON-NLS-1$
}
sb.append(daoTemplate.getInsertMethod(introspectedTable
.getIbatis2SqlMapNamespace(), introspectedTable
.getInsertStatementId(), "record")); //$NON-NLS-1$
method.addBodyLine(sb.toString());
if (returnType != null) {
if ("Object".equals(returnType.getShortName())) { //$NON-NLS-1$
// no need to cast if the return type is Object
method.addBodyLine("return newKey;"); //$NON-NLS-1$
} else {
sb.setLength(0);
if (returnType.isPrimitive()) {
PrimitiveTypeWrapper ptw = returnType
.getPrimitiveTypeWrapper();
sb.append("return (("); //$NON-NLS-1$
sb.append(ptw.getShortName());
sb.append(") newKey"); //$NON-NLS-1$
sb.append(")."); //$NON-NLS-1$
sb.append(ptw.getToPrimitiveMethod());
sb.append(';');
} else {
sb.append("return ("); //$NON-NLS-1$
sb.append(returnType.getShortName());
sb.append(") newKey;"); //$NON-NLS-1$
}
method.addBodyLine(sb.toString());
}
}
if (context.getPlugins().clientInsertMethodGenerated(method,
topLevelClass, introspectedTable)) {
topLevelClass.addImportedTypes(importedTypes);
topLevelClass.addMethod(method);
}
}
示例6: addImplementationElements
import org.mybatis.generator.api.dom.java.PrimitiveTypeWrapper; //导入依赖的package包/类
@Override
public void addImplementationElements(TopLevelClass topLevelClass) {
Set<FullyQualifiedJavaType> importedTypes = new TreeSet<FullyQualifiedJavaType>();
Method method = getMethodShell(importedTypes);
if (generateForJava5) {
method.addAnnotation("@Override"); //$NON-NLS-1$
}
FullyQualifiedJavaType returnType = method.getReturnType();
StringBuilder sb = new StringBuilder();
if (returnType != null) {
sb.append("Object newKey = "); //$NON-NLS-1$
}
sb.append(daoTemplate.getInsertMethod(introspectedTable
.getIbatis2SqlMapNamespace(), introspectedTable
.getInsertSelectiveStatementId(), "record")); //$NON-NLS-1$
method.addBodyLine(sb.toString());
if (returnType != null) {
if ("Object".equals(returnType.getShortName())) { //$NON-NLS-1$
// no need to cast if the return type is Object
method.addBodyLine("return newKey;"); //$NON-NLS-1$
} else {
sb.setLength(0);
if (returnType.isPrimitive()) {
PrimitiveTypeWrapper ptw = returnType
.getPrimitiveTypeWrapper();
sb.append("return (("); //$NON-NLS-1$
sb.append(ptw.getShortName());
sb.append(") newKey"); //$NON-NLS-1$
sb.append(")."); //$NON-NLS-1$
sb.append(ptw.getToPrimitiveMethod());
sb.append(';');
} else {
sb.append("return ("); //$NON-NLS-1$
sb.append(returnType.getShortName());
sb.append(") newKey;"); //$NON-NLS-1$
}
method.addBodyLine(sb.toString());
}
}
if (context.getPlugins().clientInsertSelectiveMethodGenerated(
method, topLevelClass, introspectedTable)) {
topLevelClass.addImportedTypes(importedTypes);
topLevelClass.addMethod(method);
}
}
示例7: addImplementationElements
import org.mybatis.generator.api.dom.java.PrimitiveTypeWrapper; //导入依赖的package包/类
@Override
public void addImplementationElements(TopLevelClass topLevelClass) {
Set<FullyQualifiedJavaType> importedTypes = new TreeSet<FullyQualifiedJavaType>();
Method method = getMethodShell(importedTypes);
FullyQualifiedJavaType returnType = method.getReturnType();
StringBuilder sb = new StringBuilder();
if (returnType != null) {
sb.append("Object newKey = "); //$NON-NLS-1$
}
sb.append(daoTemplate.getInsertMethod(introspectedTable.getIbatis2SqlMapNamespace(),
introspectedTable.getInsertStatementId(), "record")); //$NON-NLS-1$
method.addBodyLine(sb.toString());
if (returnType != null) {
if ("Object".equals(returnType.getShortName())) { //$NON-NLS-1$
// no need to cast if the return type is Object
method.addBodyLine("return newKey;"); //$NON-NLS-1$
} else {
sb.setLength(0);
if (returnType.isPrimitive()) {
PrimitiveTypeWrapper ptw = returnType.getPrimitiveTypeWrapper();
sb.append("return (("); //$NON-NLS-1$
sb.append(ptw.getShortName());
sb.append(") newKey"); //$NON-NLS-1$
sb.append(")."); //$NON-NLS-1$
sb.append(ptw.getToPrimitiveMethod());
sb.append(';');
} else {
sb.append("return ("); //$NON-NLS-1$
sb.append(returnType.getShortName());
sb.append(") newKey;"); //$NON-NLS-1$
}
method.addBodyLine(sb.toString());
}
}
if (context.getPlugins().clientInsertMethodGenerated(method, topLevelClass, introspectedTable)) {
topLevelClass.addImportedTypes(importedTypes);
topLevelClass.addMethod(method);
}
}
示例8: addImplementationElements
import org.mybatis.generator.api.dom.java.PrimitiveTypeWrapper; //导入依赖的package包/类
@Override
public void addImplementationElements(TopLevelClass topLevelClass) {
Set<FullyQualifiedJavaType> importedTypes = new TreeSet<FullyQualifiedJavaType>();
Method method = getMethodShell(importedTypes);
FullyQualifiedJavaType returnType = method.getReturnType();
StringBuilder sb = new StringBuilder();
if (returnType != null) {
sb.append("Object newKey = "); //$NON-NLS-1$
}
sb.append(daoTemplate.getInsertMethod(introspectedTable.getIbatis2SqlMapNamespace(),
introspectedTable.getInsertSelectiveStatementId(), "record")); //$NON-NLS-1$
method.addBodyLine(sb.toString());
if (returnType != null) {
if ("Object".equals(returnType.getShortName())) { //$NON-NLS-1$
// no need to cast if the return type is Object
method.addBodyLine("return newKey;"); //$NON-NLS-1$
} else {
sb.setLength(0);
if (returnType.isPrimitive()) {
PrimitiveTypeWrapper ptw = returnType.getPrimitiveTypeWrapper();
sb.append("return (("); //$NON-NLS-1$
sb.append(ptw.getShortName());
sb.append(") newKey"); //$NON-NLS-1$
sb.append(")."); //$NON-NLS-1$
sb.append(ptw.getToPrimitiveMethod());
sb.append(';');
} else {
sb.append("return ("); //$NON-NLS-1$
sb.append(returnType.getShortName());
sb.append(") newKey;"); //$NON-NLS-1$
}
method.addBodyLine(sb.toString());
}
}
if (context.getPlugins().clientInsertSelectiveMethodGenerated(method, topLevelClass, introspectedTable)) {
topLevelClass.addImportedTypes(importedTypes);
topLevelClass.addMethod(method);
}
}