CPD Results
The following document contains the results of PMD's CPD 6.55.0.
Duplications
File | Line |
---|---|
org/mybatis/generator/codegen/mybatis3/model/BaseRecordGenerator.java | 75 |
org/mybatis/generator/codegen/mybatis3/model/SimpleModelGenerator.java | 71 |
if (!introspectedTable.isImmutable()) { addDefaultConstructor(topLevelClass); } } String rootClass = getRootClass(); for (IntrospectedColumn introspectedColumn : introspectedColumns) { if (RootClassInfo.getInstance(rootClass, warnings).containsProperty(introspectedColumn)) { continue; } Field field = getJavaBeansField(introspectedColumn, context, introspectedTable); if (plugins.modelFieldGenerated(field, topLevelClass, introspectedColumn, introspectedTable, Plugin.ModelClassType.BASE_RECORD)) { topLevelClass.addField(field); topLevelClass.addImportedType(field.getType()); } Method method = getJavaBeansGetter(introspectedColumn, context, introspectedTable); if (plugins.modelGetterMethodGenerated(method, topLevelClass, introspectedColumn, introspectedTable, Plugin.ModelClassType.BASE_RECORD)) { topLevelClass.addMethod(method); } if (!introspectedTable.isImmutable()) { method = getJavaBeansSetter(introspectedColumn, context, introspectedTable); if (plugins.modelSetterMethodGenerated(method, topLevelClass, introspectedColumn, introspectedTable, Plugin.ModelClassType.BASE_RECORD)) { topLevelClass.addMethod(method); } } } List<CompilationUnit> answer = new ArrayList<>(); if (context.getPlugins().modelBaseRecordClassGenerated(topLevelClass, introspectedTable)) { answer.add(topLevelClass); } return answer; } private FullyQualifiedJavaType getSuperClass() { FullyQualifiedJavaType superClass; |
File | Line |
---|---|
org/mybatis/generator/api/dom/java/Interface.java | 36 |
org/mybatis/generator/api/dom/java/TopLevelEnumeration.java | 36 |
this(new FullyQualifiedJavaType(type)); } @Override public Set<FullyQualifiedJavaType> getImportedTypes() { return importedTypes; } @Override public void addImportedType(FullyQualifiedJavaType importedType) { if (importedType.isExplicitlyImported() && !importedType.getPackageName().equals(getType().getPackageName())) { importedTypes.add(importedType); } } @Override public void addFileCommentLine(String commentLine) { fileCommentLines.add(commentLine); } @Override public List<String> getFileCommentLines() { return fileCommentLines; } @Override public void addImportedTypes(Set<FullyQualifiedJavaType> importedTypes) { this.importedTypes.addAll(importedTypes); } @Override public Set<String> getStaticImports() { return staticImports; } @Override public void addStaticImport(String staticImport) { staticImports.add(staticImport); } @Override public void addStaticImports(Set<String> staticImports) { this.staticImports.addAll(staticImports); } @Override public <R> R accept(CompilationUnitVisitor<R> visitor) { return visitor.visit(this); } } |
File | Line |
---|---|
org/mybatis/generator/codegen/mybatis3/model/SimpleModelGenerator.java | 42 |
org/mybatis/generator/runtime/dynamic/sql/DynamicSqlModelGenerator.java | 48 |
public SimpleModelGenerator(String project) { super(project); } @Override public List<CompilationUnit> getCompilationUnits() { FullyQualifiedTable table = introspectedTable.getFullyQualifiedTable(); progressCallback.startTask(getString("Progress.8", table.toString())); //$NON-NLS-1$ Plugin plugins = context.getPlugins(); CommentGenerator commentGenerator = context.getCommentGenerator(); FullyQualifiedJavaType type = new FullyQualifiedJavaType(introspectedTable.getBaseRecordType()); TopLevelClass topLevelClass = new TopLevelClass(type); topLevelClass.setVisibility(JavaVisibility.PUBLIC); commentGenerator.addJavaFileComment(topLevelClass); FullyQualifiedJavaType superClass = getSuperClass(); if (superClass != null) { topLevelClass.setSuperClass(superClass); topLevelClass.addImportedType(superClass); } commentGenerator.addModelClassComment(topLevelClass, introspectedTable); List<IntrospectedColumn> introspectedColumns = introspectedTable.getAllColumns(); if (introspectedTable.isConstructorBased()) { addParameterizedConstructor(topLevelClass); if (!introspectedTable.isImmutable()) { |
File | Line |
---|---|
org/mybatis/generator/api/dom/java/FullyQualifiedJavaType.java | 424 |
org/mybatis/generator/api/dom/kotlin/FullyQualifiedKotlinType.java | 122 |
} } private void genericParse(String genericSpecification) { int lastIndex = genericSpecification.lastIndexOf('>'); if (lastIndex == -1) { // shouldn't happen - should be caught already, but just in case... throw new RuntimeException(getString( "RuntimeError.22", genericSpecification)); //$NON-NLS-1$ } String argumentString = genericSpecification.substring(1, lastIndex); // need to find "," outside of a <> bounds StringTokenizer st = new StringTokenizer(argumentString, ",<>", true); //$NON-NLS-1$ int openCount = 0; StringBuilder sb = new StringBuilder(); while (st.hasMoreTokens()) { String token = st.nextToken(); if ("<".equals(token)) { //$NON-NLS-1$ sb.append(token); openCount++; } else if (">".equals(token)) { //$NON-NLS-1$ sb.append(token); openCount--; } else if (",".equals(token)) { //$NON-NLS-1$ if (openCount == 0) { typeArguments .add(new FullyQualifiedJavaType(sb.toString())); |
File | Line |
---|---|
org/mybatis/generator/codegen/mybatis3/model/SimpleModelGenerator.java | 96 |
org/mybatis/generator/runtime/dynamic/sql/DynamicSqlModelGenerator.java | 110 |
method = getJavaBeansSetter(introspectedColumn, context, introspectedTable); if (plugins.modelSetterMethodGenerated(method, topLevelClass, introspectedColumn, introspectedTable, Plugin.ModelClassType.BASE_RECORD)) { topLevelClass.addMethod(method); } } } List<CompilationUnit> answer = new ArrayList<>(); if (context.getPlugins().modelBaseRecordClassGenerated(topLevelClass, introspectedTable)) { answer.add(topLevelClass); } return answer; } private FullyQualifiedJavaType getSuperClass() { FullyQualifiedJavaType superClass; String rootClass = getRootClass(); if (rootClass != null) { superClass = new FullyQualifiedJavaType(rootClass); } else { superClass = null; } return superClass; } private void addParameterizedConstructor(TopLevelClass topLevelClass) { Method method = new Method(topLevelClass.getType().getShortName()); method.setVisibility(JavaVisibility.PUBLIC); method.setConstructor(true); context.getCommentGenerator().addGeneralMethodComment(method, introspectedTable); |
File | Line |
---|---|
org/mybatis/generator/codegen/mybatis3/javamapper/JavaMapperGenerator.java | 56 |
org/mybatis/generator/codegen/mybatis3/javamapper/SimpleJavaClientGenerator.java | 47 |
public JavaMapperGenerator(String project, boolean requiresMatchedXMLGenerator) { super(project, requiresMatchedXMLGenerator); } @Override public List<CompilationUnit> getCompilationUnits() { progressCallback.startTask(getString("Progress.17", //$NON-NLS-1$ introspectedTable.getFullyQualifiedTable().toString())); CommentGenerator commentGenerator = context.getCommentGenerator(); FullyQualifiedJavaType type = new FullyQualifiedJavaType(introspectedTable.getMyBatis3JavaMapperType()); Interface interfaze = new Interface(type); interfaze.setVisibility(JavaVisibility.PUBLIC); commentGenerator.addJavaFileComment(interfaze); String rootInterface = introspectedTable.getTableConfigurationProperty(PropertyRegistry.ANY_ROOT_INTERFACE); if (!stringHasValue(rootInterface)) { rootInterface = context.getJavaClientGeneratorConfiguration() .getProperty(PropertyRegistry.ANY_ROOT_INTERFACE); } if (stringHasValue(rootInterface)) { FullyQualifiedJavaType fqjt = new FullyQualifiedJavaType(rootInterface); interfaze.addSuperInterface(fqjt); interfaze.addImportedType(fqjt); } |
File | Line |
---|---|
org/mybatis/generator/api/dom/java/Interface.java | 47 |
org/mybatis/generator/api/dom/java/TopLevelClass.java | 54 |
org/mybatis/generator/api/dom/java/TopLevelEnumeration.java | 48 |
&& !importedType.getPackageName().equals(getType().getPackageName())) { importedTypes.add(importedType); } } @Override public void addFileCommentLine(String commentLine) { fileCommentLines.add(commentLine); } @Override public List<String> getFileCommentLines() { return fileCommentLines; } @Override public void addImportedTypes(Set<FullyQualifiedJavaType> importedTypes) { this.importedTypes.addAll(importedTypes); } @Override public Set<String> getStaticImports() { return staticImports; } @Override public void addStaticImport(String staticImport) { staticImports.add(staticImport); } @Override public void addStaticImports(Set<String> staticImports) { this.staticImports.addAll(staticImports); } @Override public <R> R accept(CompilationUnitVisitor<R> visitor) { return visitor.visit(this); } } |
File | Line |
---|---|
org/mybatis/generator/codegen/mybatis3/xmlmapper/elements/SelectByExampleWithBLOBsElementGenerator.java | 37 |
org/mybatis/generator/codegen/mybatis3/xmlmapper/elements/SelectByExampleWithoutBLOBsElementGenerator.java | 37 |
"resultMap", introspectedTable.getResultMapWithBLOBsId())); //$NON-NLS-1$ answer.addAttribute(new Attribute("parameterType", introspectedTable.getExampleType())); //$NON-NLS-1$ context.getCommentGenerator().addComment(answer); answer.addElement(new TextElement("select")); //$NON-NLS-1$ XmlElement ifElement = new XmlElement("if"); //$NON-NLS-1$ ifElement.addAttribute(new Attribute("test", "distinct")); //$NON-NLS-1$ //$NON-NLS-2$ ifElement.addElement(new TextElement("distinct")); //$NON-NLS-1$ answer.addElement(ifElement); StringBuilder sb = new StringBuilder(); if (stringHasValue(introspectedTable.getSelectByExampleQueryId())) { sb.append('\''); sb.append(introspectedTable.getSelectByExampleQueryId()); sb.append("' as QUERYID,"); //$NON-NLS-1$ answer.addElement(new TextElement(sb.toString())); } answer.addElement(getBaseColumnListElement()); |
File | Line |
---|---|
org/mybatis/generator/codegen/mybatis3/model/BaseRecordGenerator.java | 43 |
org/mybatis/generator/codegen/mybatis3/model/SimpleModelGenerator.java | 42 |
org/mybatis/generator/runtime/dynamic/sql/DynamicSqlModelGenerator.java | 48 |
public BaseRecordGenerator(String project) { super(project); } @Override public List<CompilationUnit> getCompilationUnits() { FullyQualifiedTable table = introspectedTable.getFullyQualifiedTable(); progressCallback.startTask(getString("Progress.8", table.toString())); //$NON-NLS-1$ Plugin plugins = context.getPlugins(); CommentGenerator commentGenerator = context.getCommentGenerator(); FullyQualifiedJavaType type = new FullyQualifiedJavaType(introspectedTable.getBaseRecordType()); TopLevelClass topLevelClass = new TopLevelClass(type); topLevelClass.setVisibility(JavaVisibility.PUBLIC); commentGenerator.addJavaFileComment(topLevelClass); FullyQualifiedJavaType superClass = getSuperClass(); if (superClass != null) { topLevelClass.setSuperClass(superClass); topLevelClass.addImportedType(superClass); } commentGenerator.addModelClassComment(topLevelClass, introspectedTable); List<IntrospectedColumn> introspectedColumns = getColumnsInThisClass(); |
File | Line |
---|---|
org/mybatis/generator/runtime/dynamic/sql/elements/InsertMethodGenerator.java | 50 |
org/mybatis/generator/runtime/dynamic/sql/elements/InsertMultipleMethodGenerator.java | 67 |
method.addBodyLine("return MyBatis3Utils.insert(this::insert, row, " + tableFieldName //$NON-NLS-1$ + ", c ->"); //$NON-NLS-1$ List<IntrospectedColumn> columns = ListUtilities.removeIdentityAndGeneratedAlwaysColumns(introspectedTable.getAllColumns()); boolean first = true; for (IntrospectedColumn column : columns) { String fieldName = calculateFieldName(column); if (first) { method.addBodyLine(" c.map(" + fieldName //$NON-NLS-1$ + ").toProperty(\"" + column.getJavaProperty() //$NON-NLS-1$ + "\")"); //$NON-NLS-1$ first = false; } else { method.addBodyLine(" .map(" + fieldName //$NON-NLS-1$ + ").toProperty(\"" + column.getJavaProperty() //$NON-NLS-1$ + "\")"); //$NON-NLS-1$ } } method.addBodyLine(");"); //$NON-NLS-1$ return MethodAndImports.withMethod(method) .withImports(imports) .build(); } @Override public boolean callPlugins(Method method, Interface interfaze) { return context.getPlugins().clientInsertMethodGenerated(method, interfaze, introspectedTable); |
File | Line |
---|---|
org/mybatis/generator/codegen/mybatis3/model/SimpleModelGenerator.java | 127 |
org/mybatis/generator/runtime/dynamic/sql/DynamicSqlModelGenerator.java | 144 |
context.getCommentGenerator().addGeneralMethodComment(method, introspectedTable); List<IntrospectedColumn> constructorColumns = introspectedTable.getAllColumns(); for (IntrospectedColumn introspectedColumn : constructorColumns) { method.addParameter(new Parameter(introspectedColumn.getFullyQualifiedJavaType(), introspectedColumn.getJavaProperty())); } StringBuilder sb = new StringBuilder(); List<IntrospectedColumn> introspectedColumns = introspectedTable.getAllColumns(); for (IntrospectedColumn introspectedColumn : introspectedColumns) { sb.setLength(0); sb.append("this."); //$NON-NLS-1$ sb.append(introspectedColumn.getJavaProperty()); sb.append(" = "); //$NON-NLS-1$ sb.append(introspectedColumn.getJavaProperty()); sb.append(';'); method.addBodyLine(sb.toString()); } topLevelClass.addMethod(method); } } |
File | Line |
---|---|
org/mybatis/generator/runtime/kotlin/elements/InsertMethodGenerator.java | 42 |
org/mybatis/generator/runtime/kotlin/elements/InsertSelectiveMethodGenerator.java | 42 |
KotlinFunction.newOneLineFunction(mapperName + ".insert") //$NON-NLS-1$ .withArgument(KotlinArg.newArg("row") //$NON-NLS-1$ .withDataType(recordType.getShortNameWithTypeArguments()) .build()) .build()) .withImport("org.mybatis.dynamic.sql.util.kotlin.mybatis3.insert") //$NON-NLS-1$ .withImports(recordType.getImportList()) .build(); addFunctionComment(functionAndImports); KotlinFunction function = functionAndImports.getFunction(); function.addCodeLine("insert(this::insert, row, " + tableFieldName //$NON-NLS-1$ + ") {"); //$NON-NLS-1$ List<IntrospectedColumn> columns = ListUtilities.removeIdentityAndGeneratedAlwaysColumns(introspectedTable.getAllColumns()); for (IntrospectedColumn column : columns) { AbstractKotlinFunctionGenerator.FieldNameAndImport fieldNameAndImport = AbstractKotlinFunctionGenerator.calculateFieldNameAndImport(tableFieldName, supportObjectImport, column); functionAndImports.getImports().add(fieldNameAndImport.importString()); |
File | Line |
---|---|
org/mybatis/generator/runtime/kotlin/elements/InsertMethodGenerator.java | 55 |
org/mybatis/generator/runtime/kotlin/elements/InsertMultipleMethodGenerator.java | 76 |
function.addCodeLine("insert(this::insert, row, " + tableFieldName //$NON-NLS-1$ + ") {"); //$NON-NLS-1$ List<IntrospectedColumn> columns = ListUtilities.removeIdentityAndGeneratedAlwaysColumns(introspectedTable.getAllColumns()); for (IntrospectedColumn column : columns) { AbstractKotlinFunctionGenerator.FieldNameAndImport fieldNameAndImport = AbstractKotlinFunctionGenerator.calculateFieldNameAndImport(tableFieldName, supportObjectImport, column); functionAndImports.getImports().add(fieldNameAndImport.importString()); function.addCodeLine(" map(" + fieldNameAndImport.fieldName() //$NON-NLS-1$ + ") toProperty \"" + column.getJavaProperty() //$NON-NLS-1$ + "\""); //$NON-NLS-1$ } function.addCodeLine("}"); //$NON-NLS-1$ return functionAndImports; } @Override public boolean callPlugins(KotlinFunction kotlinFunction, KotlinFile kotlinFile) { return context.getPlugins().clientInsertMethodGenerated(kotlinFunction, kotlinFile, introspectedTable); |
File | Line |
---|---|
org/mybatis/generator/logging/commons/JakartaCommonsLoggingImpl.java | 26 |
org/mybatis/generator/logging/slf4j/Slf4jImpl.java | 44 |
log = LogFactory.getLog(clazz); } @Override public boolean isDebugEnabled() { return log.isDebugEnabled(); } @Override public void error(String s, Throwable e) { log.error(s, e); } @Override public void error(String s) { log.error(s); } @Override public void debug(String s) { log.debug(s); } @Override public void warn(String s) { log.warn(s); } @Override public void info(String s) { log.info(s); } } |
File | Line |
---|---|
org/mybatis/generator/logging/commons/JakartaCommonsLoggingImpl.java | 27 |
org/mybatis/generator/logging/log4j2/Log4j2Impl.java | 35 |
org/mybatis/generator/logging/slf4j/Slf4jImpl.java | 45 |
org/mybatis/generator/logging/slf4j/Slf4jLoggerImpl.java | 27 |
} @Override public boolean isDebugEnabled() { return log.isDebugEnabled(); } @Override public void error(String s, Throwable e) { log.error(s, e); } @Override public void error(String s) { log.error(s); } @Override public void debug(String s) { log.debug(s); } @Override public void warn(String s) { log.warn(s); } @Override public void info(String s) { log.info(s); } } |
File | Line |
---|---|
org/mybatis/generator/codegen/mybatis3/xmlmapper/SimpleXMLMapperGenerator.java | 94 |
org/mybatis/generator/codegen/mybatis3/xmlmapper/XMLMapperGenerator.java | 221 |
AbstractXmlElementGenerator elementGenerator = new UpdateByPrimaryKeyWithoutBLOBsElementGenerator(true); initializeAndExecuteGenerator(elementGenerator, parentElement); } } protected void initializeAndExecuteGenerator(AbstractXmlElementGenerator elementGenerator, XmlElement parentElement) { elementGenerator.setContext(context); elementGenerator.setIntrospectedTable(introspectedTable); elementGenerator.setProgressCallback(progressCallback); elementGenerator.setWarnings(warnings); elementGenerator.addElements(parentElement); } @Override public Document getDocument() { Document document = new Document(XmlConstants.MYBATIS3_MAPPER_PUBLIC_ID, XmlConstants.MYBATIS3_MAPPER_SYSTEM_ID); document.setRootElement(getSqlMapElement()); if (!context.getPlugins().sqlMapDocumentGenerated(document, introspectedTable)) { document = null; } return document; } } |