本文整理汇总了Java中org.mybatis.generator.api.dom.java.Method.addParameter方法的典型用法代码示例。如果您正苦于以下问题:Java Method.addParameter方法的具体用法?Java Method.addParameter怎么用?Java Method.addParameter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.mybatis.generator.api.dom.java.Method
的用法示例。
在下文中一共展示了Method.addParameter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getMethodShell
import org.mybatis.generator.api.dom.java.Method; //导入方法依赖的package包/类
private Method getMethodShell(Set<FullyQualifiedJavaType> importedTypes) {
FullyQualifiedJavaType type = new FullyQualifiedJavaType(
introspectedTable.getExampleType());
importedTypes.add(type);
Method method = new Method();
method.setVisibility(getExampleMethodVisibility());
method.setReturnType(FullyQualifiedJavaType.getIntInstance());
method.setName(getDAOMethodNameCalculator()
.getDeleteByExampleMethodName(introspectedTable));
method.addParameter(new Parameter(type, "example")); //$NON-NLS-1$
for (FullyQualifiedJavaType fqjt : daoTemplate.getCheckedExceptions()) {
method.addException(fqjt);
importedTypes.add(fqjt);
}
context.getCommentGenerator().addGeneralMethodComment(method,
introspectedTable);
return method;
}
示例2: clientUpdateByPrimaryKeySelectiveMethodGenerated
import org.mybatis.generator.api.dom.java.Method; //导入方法依赖的package包/类
@Override
public boolean clientUpdateByPrimaryKeySelectiveMethodGenerated(
Method method, Interface interfaze,
IntrospectedTable introspectedTable) {
if (ignore(introspectedTable)) {
return true;
}
Method m = new Method();
m.setName("updateByPrimaryKeySelectiveWithVersion");
copyMethod(m, method, null);
m.addParameter(new Parameter(new FullyQualifiedJavaType(
"java.lang.Integer"), "version", "@Param(\"version\")"));
m.addException(new FullyQualifiedJavaType(optimisticLockException));
interfaze.addMethod(m);
interfaze.addImportedType(new FullyQualifiedJavaType(optimisticLockException));
return true;
}
示例3: addInterfaceElements
import org.mybatis.generator.api.dom.java.Method; //导入方法依赖的package包/类
@Override
public void addInterfaceElements(Interface interfaze) {
Set<FullyQualifiedJavaType> importedTypes = new TreeSet<FullyQualifiedJavaType>();
Method method = new Method();
method.setReturnType(FullyQualifiedJavaType.getIntInstance());
method.setVisibility(JavaVisibility.PUBLIC);
method.setName(introspectedTable.getInsertSelectiveStatementId());
FullyQualifiedJavaType parameterType = introspectedTable.getRules()
.calculateAllFieldsClass();
importedTypes.add(parameterType);
method.addParameter(new Parameter(parameterType, "record")); //$NON-NLS-1$
context.getCommentGenerator().addGeneralMethodComment(method,
introspectedTable);
addMapperAnnotations(interfaze, method);
if (context.getPlugins().clientInsertSelectiveMethodGenerated(
method, interfaze, introspectedTable)) {
interfaze.addImportedTypes(importedTypes);
interfaze.addMethod(method);
}
}
示例4: getConstructorClone
import org.mybatis.generator.api.dom.java.Method; //导入方法依赖的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;
}
示例5: getMethodShell
import org.mybatis.generator.api.dom.java.Method; //导入方法依赖的package包/类
private Method getMethodShell(Set<FullyQualifiedJavaType> importedTypes) {
FullyQualifiedJavaType parameterType = new FullyQualifiedJavaType(
introspectedTable.getBaseRecordType());
importedTypes.add(parameterType);
Method method = new Method();
method.setVisibility(JavaVisibility.PUBLIC);
method.setReturnType(FullyQualifiedJavaType.getIntInstance());
method
.setName(getDAOMethodNameCalculator()
.getUpdateByPrimaryKeyWithoutBLOBsMethodName(
introspectedTable));
method.addParameter(new Parameter(parameterType, "record")); //$NON-NLS-1$
for (FullyQualifiedJavaType fqjt : daoTemplate.getCheckedExceptions()) {
method.addException(fqjt);
importedTypes.add(fqjt);
}
context.getCommentGenerator().addGeneralMethodComment(method,
introspectedTable);
return method;
}
开发者ID:xiachengwei5,项目名称:org.mybatis.generator.core-1.3.5,代码行数:25,代码来源:UpdateByPrimaryKeyWithoutBLOBsMethodGenerator.java
示例6: configureConstructorTemplate
import org.mybatis.generator.api.dom.java.Method; //导入方法依赖的package包/类
@Override
protected void configureConstructorTemplate() {
Method constructor = new Method();
constructor.setConstructor(true);
constructor.setVisibility(JavaVisibility.PUBLIC);
constructor
.addParameter(new Parameter(sqlMapClientType, "sqlMapClient")); //$NON-NLS-1$
constructor.addBodyLine("super();"); //$NON-NLS-1$
constructor.addBodyLine("this.sqlMapClient = sqlMapClient;"); //$NON-NLS-1$
setConstructorTemplate(constructor);
}
示例7: addInterfaceElements
import org.mybatis.generator.api.dom.java.Method; //导入方法依赖的package包/类
@Override
public void addInterfaceElements(Interface interfaze) {
Set<FullyQualifiedJavaType> importedTypes = new TreeSet<FullyQualifiedJavaType>();
Method method = new Method();
method.setReturnType(FullyQualifiedJavaType.getIntInstance());
method.setVisibility(JavaVisibility.PUBLIC);
method.setName(introspectedTable.getInsertSelectiveStatementId());
FullyQualifiedJavaType parameterType = introspectedTable.getRules()
.calculateAllFieldsClass();
importedTypes.add(parameterType);
method.addParameter(new Parameter(parameterType, "record")); //$NON-NLS-1$
context.getCommentGenerator().addGeneralMethodComment(method,
introspectedTable);
addMapperAnnotations(method);
if (context.getPlugins().clientInsertSelectiveMethodGenerated(
method, interfaze, introspectedTable)) {
addExtraImports(interfaze);
interfaze.addImportedTypes(importedTypes);
interfaze.addMethod(method);
}
}
示例8: getMethodClones
import org.mybatis.generator.api.dom.java.Method; //导入方法依赖的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;
}
示例9: addInterfaceElements
import org.mybatis.generator.api.dom.java.Method; //导入方法依赖的package包/类
@Override
public void addInterfaceElements(Interface interfaze) {
Set<FullyQualifiedJavaType> importedTypes = new TreeSet<FullyQualifiedJavaType>();
Method method = new Method();
method.setVisibility(JavaVisibility.PUBLIC);
method.setReturnType(FullyQualifiedJavaType.getIntInstance());
method.setName(introspectedTable
.getUpdateByExampleSelectiveStatementId());
FullyQualifiedJavaType parameterType =
introspectedTable.getRules().calculateAllFieldsClass();
method.addParameter(new Parameter(parameterType,
"record", "@Param(\"record\")")); //$NON-NLS-1$ //$NON-NLS-2$
importedTypes.add(parameterType);
FullyQualifiedJavaType exampleType = new FullyQualifiedJavaType(
introspectedTable.getExampleType());
method.addParameter(new Parameter(exampleType,
"example", "@Param(\"example\")")); //$NON-NLS-1$ //$NON-NLS-2$
importedTypes.add(exampleType);
importedTypes.add(new FullyQualifiedJavaType(
"org.apache.ibatis.annotations.Param")); //$NON-NLS-1$
context.getCommentGenerator().addGeneralMethodComment(method,
introspectedTable);
addMapperAnnotations(method);
if (context.getPlugins()
.clientUpdateByExampleSelectiveMethodGenerated(method, interfaze,
introspectedTable)) {
addExtraImports(interfaze);
interfaze.addImportedTypes(importedTypes);
interfaze.addMethod(method);
}
}
示例10: configureConstructorTemplate
import org.mybatis.generator.api.dom.java.Method; //导入方法依赖的package包/类
@Override
protected void configureConstructorTemplate() {
Method method = new Method();
method.setConstructor(true);
method.setVisibility(JavaVisibility.PUBLIC);
method.addParameter(new Parameter(fqjt, "daoManager")); //$NON-NLS-1$
method.addBodyLine("super(daoManager);"); //$NON-NLS-1$
setConstructorTemplate(method);
}
示例11: getMethodShell
import org.mybatis.generator.api.dom.java.Method; //导入方法依赖的package包/类
private Method getMethodShell(Set<FullyQualifiedJavaType> importedTypes) {
Method method = new Method();
FullyQualifiedJavaType returnType;
if (introspectedTable.getGeneratedKey() != null) {
IntrospectedColumn introspectedColumn = introspectedTable
.getColumn(introspectedTable.getGeneratedKey().getColumn());
if (introspectedColumn == null) {
// the specified column doesn't exist, so don't do the generated
// key
// (the warning has already been reported)
returnType = null;
} else {
returnType = introspectedColumn.getFullyQualifiedJavaType();
importedTypes.add(returnType);
}
} else {
returnType = null;
}
method.setReturnType(returnType);
method.setVisibility(JavaVisibility.PUBLIC);
DAOMethodNameCalculator methodNameCalculator = getDAOMethodNameCalculator();
method.setName(methodNameCalculator
.getInsertMethodName(introspectedTable));
FullyQualifiedJavaType parameterType = introspectedTable.getRules()
.calculateAllFieldsClass();
importedTypes.add(parameterType);
method.addParameter(new Parameter(parameterType, "record")); //$NON-NLS-1$
for (FullyQualifiedJavaType fqjt : daoTemplate.getCheckedExceptions()) {
method.addException(fqjt);
importedTypes.add(fqjt);
}
context.getCommentGenerator().addGeneralMethodComment(method,
introspectedTable);
return method;
}
示例12: modelExampleClassGenerated
import org.mybatis.generator.api.dom.java.Method; //导入方法依赖的package包/类
@Override
public boolean modelExampleClassGenerated(TopLevelClass topLevelClass,
IntrospectedTable introspectedTable) {
InnerClass criteria = null;
// first, find the Criteria inner class
for (InnerClass innerClass : topLevelClass.getInnerClasses()) {
if ("GeneratedCriteria".equals(innerClass.getType().getShortName())) { //$NON-NLS-1$
criteria = innerClass;
break;
}
}
if (criteria == null) {
// can't find the inner class for some reason, bail out.
return true;
}
for (IntrospectedColumn introspectedColumn : introspectedTable
.getNonBLOBColumns()) {
if (!introspectedColumn.isJdbcCharacterColumn()
|| !introspectedColumn.isStringColumn()) {
continue;
}
Method method = new Method();
method.setVisibility(JavaVisibility.PUBLIC);
method.addParameter(new Parameter(introspectedColumn
.getFullyQualifiedJavaType(), "value")); //$NON-NLS-1$
StringBuilder sb = new StringBuilder();
sb.append(introspectedColumn.getJavaProperty());
sb.setCharAt(0, Character.toUpperCase(sb.charAt(0)));
sb.insert(0, "and"); //$NON-NLS-1$
sb.append("LikeInsensitive"); //$NON-NLS-1$
method.setName(sb.toString());
method.setReturnType(FullyQualifiedJavaType.getCriteriaInstance());
sb.setLength(0);
sb.append("addCriterion(\"upper("); //$NON-NLS-1$
sb.append(Ibatis2FormattingUtilities
.getAliasedActualColumnName(introspectedColumn));
sb.append(") like\", value.toUpperCase(), \""); //$NON-NLS-1$
sb.append(introspectedColumn.getJavaProperty());
sb.append("\");"); //$NON-NLS-1$
method.addBodyLine(sb.toString());
method.addBodyLine("return (Criteria) this;"); //$NON-NLS-1$
criteria.addMethod(method);
}
return true;
}
开发者ID:xiachengwei5,项目名称:org.mybatis.generator.core-1.3.5,代码行数:54,代码来源:CaseInsensitiveLikePlugin.java
示例13: getSingleValueMethod
import org.mybatis.generator.api.dom.java.Method; //导入方法依赖的package包/类
private Method getSingleValueMethod(IntrospectedColumn introspectedColumn,
String nameFragment, String operator) {
Method method = new Method();
method.setVisibility(JavaVisibility.PUBLIC);
method.addParameter(new Parameter(introspectedColumn
.getFullyQualifiedJavaType(), "value")); //$NON-NLS-1$
StringBuilder sb = new StringBuilder();
sb.append(introspectedColumn.getJavaProperty());
sb.setCharAt(0, Character.toUpperCase(sb.charAt(0)));
sb.insert(0, "and"); //$NON-NLS-1$
sb.append(nameFragment);
method.setName(sb.toString());
method.setReturnType(FullyQualifiedJavaType.getCriteriaInstance());
sb.setLength(0);
if (introspectedColumn.isJDBCDateColumn()) {
sb.append("addCriterionForJDBCDate(\""); //$NON-NLS-1$
} else if (introspectedColumn.isJDBCTimeColumn()) {
sb.append("addCriterionForJDBCTime(\""); //$NON-NLS-1$
} else if (stringHasValue(introspectedColumn
.getTypeHandler())) {
sb.append("add"); //$NON-NLS-1$
sb.append(introspectedColumn.getJavaProperty());
sb.setCharAt(3, Character.toUpperCase(sb.charAt(3)));
sb.append("Criterion(\""); //$NON-NLS-1$
} else {
sb.append("addCriterion(\""); //$NON-NLS-1$
}
sb.append(Ibatis2FormattingUtilities
.getAliasedActualColumnName(introspectedColumn));
sb.append(' ');
sb.append(operator);
sb.append("\", "); //$NON-NLS-1$
if (introspectedColumn.getFullyQualifiedJavaType().isPrimitive() && !introspectedTable.isJava5Targeted()) {
sb.append("new "); //$NON-NLS-1$
sb.append(introspectedColumn.getFullyQualifiedJavaType()
.getPrimitiveTypeWrapper().getShortName());
sb.append("(value)"); //$NON-NLS-1$
} else {
sb.append("value"); //$NON-NLS-1$
}
sb.append(", \""); //$NON-NLS-1$
sb.append(introspectedColumn.getJavaProperty());
sb.append("\");"); //$NON-NLS-1$
method.addBodyLine(sb.toString());
method.addBodyLine("return (Criteria) this;"); //$NON-NLS-1$
return method;
}
示例14: addClassElements
import org.mybatis.generator.api.dom.java.Method; //导入方法依赖的package包/类
@Override
public void addClassElements(TopLevelClass topLevelClass) {
Set<String> staticImports = new TreeSet<String>();
Set<FullyQualifiedJavaType> importedTypes = new TreeSet<FullyQualifiedJavaType>();
if (useLegacyBuilder) {
staticImports.add("org.apache.ibatis.jdbc.SqlBuilder.BEGIN"); //$NON-NLS-1$
staticImports.add("org.apache.ibatis.jdbc.SqlBuilder.DELETE_FROM"); //$NON-NLS-1$
staticImports.add("org.apache.ibatis.jdbc.SqlBuilder.SQL"); //$NON-NLS-1$
} else {
importedTypes.add(NEW_BUILDER_IMPORT);
}
FullyQualifiedJavaType fqjt = new FullyQualifiedJavaType(introspectedTable.getExampleType());
importedTypes.add(fqjt);
Method method = new Method(
introspectedTable.getDeleteByExampleStatementId());
method.setVisibility(JavaVisibility.PUBLIC);
method.setReturnType(FullyQualifiedJavaType.getStringInstance());
method.addParameter(new Parameter(fqjt, "example")); //$NON-NLS-1$
context.getCommentGenerator().addGeneralMethodComment(method,
introspectedTable);
if (useLegacyBuilder) {
method.addBodyLine("BEGIN();"); //$NON-NLS-1$
method.addBodyLine(String.format("DELETE_FROM(\"%s\");", //$NON-NLS-1$
escapeStringForJava(introspectedTable.getAliasedFullyQualifiedTableNameAtRuntime())));
method.addBodyLine("applyWhere(example, false);"); //$NON-NLS-1$
method.addBodyLine("return SQL();"); //$NON-NLS-1$
} else {
method.addBodyLine("SQL sql = new SQL();"); //$NON-NLS-1$
method.addBodyLine(String.format("sql.DELETE_FROM(\"%s\");", //$NON-NLS-1$
escapeStringForJava(introspectedTable.getAliasedFullyQualifiedTableNameAtRuntime())));
method.addBodyLine("applyWhere(sql, example, false);"); //$NON-NLS-1$
method.addBodyLine("return sql.toString();"); //$NON-NLS-1$
}
if (context.getPlugins().providerDeleteByExampleMethodGenerated(method, topLevelClass,
introspectedTable)) {
topLevelClass.addStaticImports(staticImports);
topLevelClass.addImportedTypes(importedTypes);
topLevelClass.addMethod(method);
}
}
示例15: getSetBetweenOrNotBetweenMethod
import org.mybatis.generator.api.dom.java.Method; //导入方法依赖的package包/类
/**
* Generates methods that set between and not between conditions.
*
* @param introspectedColumn
* @param betweenMethod
* @return a generated method for the between or not between method
*/
private Method getSetBetweenOrNotBetweenMethod(
IntrospectedColumn introspectedColumn, boolean betweenMethod) {
Method method = new Method();
method.setVisibility(JavaVisibility.PUBLIC);
FullyQualifiedJavaType type = introspectedColumn
.getFullyQualifiedJavaType();
method.addParameter(new Parameter(type, "value1")); //$NON-NLS-1$
method.addParameter(new Parameter(type, "value2")); //$NON-NLS-1$
StringBuilder sb = new StringBuilder();
sb.append(introspectedColumn.getJavaProperty());
sb.setCharAt(0, Character.toUpperCase(sb.charAt(0)));
sb.insert(0, "and"); //$NON-NLS-1$
if (betweenMethod) {
sb.append("Between"); //$NON-NLS-1$
} else {
sb.append("NotBetween"); //$NON-NLS-1$
}
method.setName(sb.toString());
method.setReturnType(FullyQualifiedJavaType.getCriteriaInstance());
sb.setLength(0);
if (introspectedColumn.isJDBCDateColumn()) {
sb.append("addCriterionForJDBCDate(\""); //$NON-NLS-1$
} else if (introspectedColumn.isJDBCTimeColumn()) {
sb.append("addCriterionForJDBCTime(\""); //$NON-NLS-1$
} else if (stringHasValue(introspectedColumn
.getTypeHandler())) {
sb.append("add"); //$NON-NLS-1$
sb.append(introspectedColumn.getJavaProperty());
sb.setCharAt(3, Character.toUpperCase(sb.charAt(3)));
sb.append("Criterion(\""); //$NON-NLS-1$
} else {
sb.append("addCriterion(\""); //$NON-NLS-1$
}
sb.append(Ibatis2FormattingUtilities
.getAliasedActualColumnName(introspectedColumn));
if (betweenMethod) {
sb.append(" between"); //$NON-NLS-1$
} else {
sb.append(" not between"); //$NON-NLS-1$
}
sb.append("\", "); //$NON-NLS-1$
if (introspectedColumn.getFullyQualifiedJavaType().isPrimitive() && !introspectedTable.isJava5Targeted()) {
sb.append("new "); //$NON-NLS-1$
sb.append(introspectedColumn.getFullyQualifiedJavaType()
.getPrimitiveTypeWrapper().getShortName());
sb.append("(value1), "); //$NON-NLS-1$
sb.append("new "); //$NON-NLS-1$
sb.append(introspectedColumn.getFullyQualifiedJavaType()
.getPrimitiveTypeWrapper().getShortName());
sb.append("(value2)"); //$NON-NLS-1$
} else {
sb.append("value1, value2"); //$NON-NLS-1$
}
sb.append(", \""); //$NON-NLS-1$
sb.append(introspectedColumn.getJavaProperty());
sb.append("\");"); //$NON-NLS-1$
method.addBodyLine(sb.toString());
method.addBodyLine("return (Criteria) this;"); //$NON-NLS-1$
return method;
}