Java Code Examples for org.mybatis.generator.api.dom.java.Parameter#getType()
The following examples show how to use
org.mybatis.generator.api.dom.java.Parameter#getType() .
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: RenameExampleClassAndMethodsPlugin.java From mybatis-generator-plugins with Apache License 2.0 | 6 votes |
boolean renameMethod(Method method) { String oldMethodName = method.getName(); Matcher matcher = classMethodPattern.matcher(oldMethodName); String newMethodName = matcher.replaceAll(classMethodReplaceString); method.setName(newMethodName); for (int i = 0; i < method.getParameters().size(); i++) { Parameter parameter = method.getParameters().get(i); String oldParamName = parameter.getName(); matcher = parameterPattern.matcher(oldParamName); if (matcher.lookingAt()) { String newName = matcher.replaceAll(parameterReplaceString); Parameter newParam = new Parameter(parameter.getType(), newName, parameter.isVarargs()); for (String annotation : parameter.getAnnotations()) { newParam.addAnnotation(annotation); } method.getParameters().set(i, newParam); } } return true; }
Example 2
Source File: CreateGenericInterfacePlugin.java From mybatis-generator-plugins with Apache License 2.0 | 6 votes |
void addGenericMethod(Method method, FullyQualifiedJavaType returnType, FullyQualifiedJavaType... types) { method.addAnnotation("@Override"); if (!methodsAdded.contains(method.getName())) { Method genericMethod = new Method(method.getName()); genericMethod.addJavaDocLine("/**"); genericMethod.addJavaDocLine(" * This method was generated by MyBatis Generator."); genericMethod.addJavaDocLine(" *"); genericMethod.addJavaDocLine(" * @mbg.generated"); genericMethod.addJavaDocLine(" */"); genericMethod.setReturnType(returnType); for (int i = 0; i < method.getParameters().size(); i++) { Parameter parameter = method.getParameters().get(i); FullyQualifiedJavaType paramType = types.length > i ? types[i] : parameter.getType(); Parameter genericParameter = new Parameter(paramType, parameter.getName()); genericMethod.addParameter(genericParameter); } genericInterface.addMethod(genericMethod); methodsAdded.add(method.getName()); } }
Example 3
Source File: CreateSubPackagePlugin.java From mybatis-generator-plugins with Apache License 2.0 | 6 votes |
/** * Rename the method types. * * @param method * the method * @return true */ boolean renameMethod(Method method) { method.setReturnType(modelProperties.renameType(method.getReturnType())); for (int i = 0; i < method.getParameters().size(); i++) { Parameter parameter = method.getParameters().get(i); FullyQualifiedJavaType parameterType = parameter.getType(); FullyQualifiedJavaType newParameterType = modelProperties.renameType(parameterType); if (parameterType != newParameterType) { Parameter newParam = new Parameter(newParameterType, parameter.getName(), parameter.isVarargs()); for (String annotation : parameter.getAnnotations()) { newParam.addAnnotation(annotation); } method.getParameters().set(i, newParam); log.debug("set new parameter: [{}][{}]", parameter, newParam); } } modelProperties.renameAnnotations(method.getAnnotations()); mapperProperties.renameAnnotations(method.getAnnotations()); return true; }
Example 4
Source File: JavaElementTools.java From mybatis-generator-plugin with Apache License 2.0 | 5 votes |
/** * clone * @param parameter * @return */ public static Parameter clone(Parameter parameter) { Parameter dest = new Parameter(parameter.getType(), parameter.getName(), parameter.isVarargs()); for (String annotation : parameter.getAnnotations()) { dest.addAnnotation(annotation); } return dest; }