├── .gitignore ├── README.md ├── mybatis-generator-core ├── pom.properties ├── pom.xml └── src │ └── main │ ├── assembly │ └── src.xml │ ├── java │ └── org │ │ └── mybatis │ │ └── generator │ │ ├── ant │ │ ├── AntProgressCallback.java │ │ └── GeneratorAntTask.java │ │ ├── api │ │ ├── CommentGenerator.java │ │ ├── CompositePlugin.java │ │ ├── ConnectionFactory.java │ │ ├── FullyQualifiedTable.java │ │ ├── GeneratedFile.java │ │ ├── GeneratedJavaFile.java │ │ ├── GeneratedKotlinFile.java │ │ ├── GeneratedXmlFile.java │ │ ├── IntrospectedColumn.java │ │ ├── IntrospectedTable.java │ │ ├── JavaFormatter.java │ │ ├── JavaTypeResolver.java │ │ ├── KotlinFormatter.java │ │ ├── MyBatisGenerator.java │ │ ├── Plugin.java │ │ ├── PluginAdapter.java │ │ ├── ProgressCallback.java │ │ ├── ShellCallback.java │ │ ├── ShellRunner.java │ │ ├── VerboseProgressCallback.java │ │ ├── XmlFormatter.java │ │ ├── dom │ │ │ ├── DefaultJavaFormatter.java │ │ │ ├── DefaultKotlinFormatter.java │ │ │ ├── DefaultXmlFormatter.java │ │ │ ├── OutputUtilities.java │ │ │ ├── java │ │ │ │ ├── AbstractJavaType.java │ │ │ │ ├── CompilationUnit.java │ │ │ │ ├── CompilationUnitVisitor.java │ │ │ │ ├── Field.java │ │ │ │ ├── FullyQualifiedJavaType.java │ │ │ │ ├── InitializationBlock.java │ │ │ │ ├── InnerClass.java │ │ │ │ ├── InnerEnum.java │ │ │ │ ├── InnerInterface.java │ │ │ │ ├── Interface.java │ │ │ │ ├── JavaDomUtils.java │ │ │ │ ├── JavaElement.java │ │ │ │ ├── JavaReservedWords.java │ │ │ │ ├── JavaVisibility.java │ │ │ │ ├── Method.java │ │ │ │ ├── Parameter.java │ │ │ │ ├── PrimitiveTypeWrapper.java │ │ │ │ ├── TopLevelClass.java │ │ │ │ ├── TopLevelEnumeration.java │ │ │ │ ├── TypeParameter.java │ │ │ │ └── render │ │ │ │ │ ├── BodyLineRenderer.java │ │ │ │ │ ├── FieldRenderer.java │ │ │ │ │ ├── InitializationBlockRenderer.java │ │ │ │ │ ├── InnerClassRenderer.java │ │ │ │ │ ├── InnerEnumRenderer.java │ │ │ │ │ ├── InnerInterfaceRenderer.java │ │ │ │ │ ├── MethodRenderer.java │ │ │ │ │ ├── ParameterRenderer.java │ │ │ │ │ ├── RenderingUtilities.java │ │ │ │ │ ├── TopLevelClassRenderer.java │ │ │ │ │ ├── TopLevelEnumerationRenderer.java │ │ │ │ │ ├── TopLevelInterfaceRenderer.java │ │ │ │ │ └── TypeParameterRenderer.java │ │ │ ├── kotlin │ │ │ │ ├── FullyQualifiedKotlinType.java │ │ │ │ ├── JavaToKotlinTypeConverter.java │ │ │ │ ├── KotlinArg.java │ │ │ │ ├── KotlinFile.java │ │ │ │ ├── KotlinFunction.java │ │ │ │ ├── KotlinModifier.java │ │ │ │ ├── KotlinNamedItem.java │ │ │ │ ├── KotlinNamedItemContainer.java │ │ │ │ ├── KotlinNamedItemVisitor.java │ │ │ │ ├── KotlinProperty.java │ │ │ │ ├── KotlinType.java │ │ │ │ └── render │ │ │ │ │ ├── KotlinArgRenderer.java │ │ │ │ │ ├── KotlinFileRenderer.java │ │ │ │ │ ├── KotlinFunctionRenderer.java │ │ │ │ │ ├── KotlinNamedItemRenderer.java │ │ │ │ │ ├── KotlinPropertyRenderer.java │ │ │ │ │ ├── KotlinRenderingUtilities.java │ │ │ │ │ └── KotlinTypeRenderer.java │ │ │ └── xml │ │ │ │ ├── Attribute.java │ │ │ │ ├── DocType.java │ │ │ │ ├── DocTypeVisitor.java │ │ │ │ ├── Document.java │ │ │ │ ├── ElementVisitor.java │ │ │ │ ├── PublicDocType.java │ │ │ │ ├── SystemDocType.java │ │ │ │ ├── TextElement.java │ │ │ │ ├── VisitableElement.java │ │ │ │ ├── XmlElement.java │ │ │ │ └── render │ │ │ │ ├── AttributeRenderer.java │ │ │ │ ├── DocTypeRenderer.java │ │ │ │ ├── DocumentRenderer.java │ │ │ │ └── ElementRenderer.java │ │ └── package.html │ │ ├── codegen │ │ ├── AbstractGenerator.java │ │ ├── AbstractJavaClientGenerator.java │ │ ├── AbstractJavaGenerator.java │ │ ├── AbstractKotlinGenerator.java │ │ ├── AbstractXmlGenerator.java │ │ ├── RootClassInfo.java │ │ ├── XmlConstants.java │ │ └── mybatis3 │ │ │ ├── IntrospectedTableMyBatis3Impl.java │ │ │ ├── IntrospectedTableMyBatis3SimpleImpl.java │ │ │ ├── ListUtilities.java │ │ │ ├── MyBatis3FormattingUtilities.java │ │ │ ├── javamapper │ │ │ ├── AnnotatedClientGenerator.java │ │ │ ├── JavaMapperGenerator.java │ │ │ ├── MixedClientGenerator.java │ │ │ ├── SimpleAnnotatedClientGenerator.java │ │ │ ├── SimpleJavaClientGenerator.java │ │ │ ├── SqlProviderGenerator.java │ │ │ └── elements │ │ │ │ ├── AbstractJavaMapperMethodGenerator.java │ │ │ │ ├── BatchInsertMethodGenerator.java │ │ │ │ ├── BatchUpdateMethodGenerator.java │ │ │ │ ├── BatchUpdateSelectiveMethodGenerator.java │ │ │ │ ├── CountByExampleMethodGenerator.java │ │ │ │ ├── DeleteByExampleMethodGenerator.java │ │ │ │ ├── DeleteByPrimaryKeyMethodGenerator.java │ │ │ │ ├── InsertMethodGenerator.java │ │ │ │ ├── InsertSelectiveMethodGenerator.java │ │ │ │ ├── SelectAllMethodGenerator.java │ │ │ │ ├── SelectByExampleWithBLOBsMethodGenerator.java │ │ │ │ ├── SelectByExampleWithoutBLOBsMethodGenerator.java │ │ │ │ ├── SelectByPrimaryKeyMethodGenerator.java │ │ │ │ ├── SelectFirstByExampleMethodGenerator.java │ │ │ │ ├── UpdateByExampleSelectiveMethodGenerator.java │ │ │ │ ├── UpdateByExampleWithBLOBsMethodGenerator.java │ │ │ │ ├── UpdateByExampleWithoutBLOBsMethodGenerator.java │ │ │ │ ├── UpdateByPrimaryKeySelectiveMethodGenerator.java │ │ │ │ ├── UpdateByPrimaryKeyWithBLOBsMethodGenerator.java │ │ │ │ ├── UpdateByPrimaryKeyWithoutBLOBsMethodGenerator.java │ │ │ │ ├── annotated │ │ │ │ ├── AnnotatedCountByExampleMethodGenerator.java │ │ │ │ ├── AnnotatedDeleteByExampleMethodGenerator.java │ │ │ │ ├── AnnotatedDeleteByPrimaryKeyMethodGenerator.java │ │ │ │ ├── AnnotatedInsertMethodGenerator.java │ │ │ │ ├── AnnotatedInsertSelectiveMethodGenerator.java │ │ │ │ ├── AnnotatedSelectAllMethodGenerator.java │ │ │ │ ├── AnnotatedSelectByExampleWithBLOBsMethodGenerator.java │ │ │ │ ├── AnnotatedSelectByExampleWithoutBLOBsMethodGenerator.java │ │ │ │ ├── AnnotatedSelectByPrimaryKeyMethodGenerator.java │ │ │ │ ├── AnnotatedUpdateByExampleSelectiveMethodGenerator.java │ │ │ │ ├── AnnotatedUpdateByExampleWithBLOBsMethodGenerator.java │ │ │ │ ├── AnnotatedUpdateByExampleWithoutBLOBsMethodGenerator.java │ │ │ │ ├── AnnotatedUpdateByPrimaryKeySelectiveMethodGenerator.java │ │ │ │ ├── AnnotatedUpdateByPrimaryKeyWithBLOBsMethodGenerator.java │ │ │ │ └── AnnotatedUpdateByPrimaryKeyWithoutBLOBsMethodGenerator.java │ │ │ │ └── sqlprovider │ │ │ │ ├── AbstractJavaProviderMethodGenerator.java │ │ │ │ ├── ProviderApplyWhereMethodGenerator.java │ │ │ │ ├── ProviderCountByExampleMethodGenerator.java │ │ │ │ ├── ProviderDeleteByExampleMethodGenerator.java │ │ │ │ ├── ProviderInsertSelectiveMethodGenerator.java │ │ │ │ ├── ProviderSelectByExampleWithBLOBsMethodGenerator.java │ │ │ │ ├── ProviderSelectByExampleWithoutBLOBsMethodGenerator.java │ │ │ │ ├── ProviderUpdateByExampleSelectiveMethodGenerator.java │ │ │ │ ├── ProviderUpdateByExampleWithBLOBsMethodGenerator.java │ │ │ │ ├── ProviderUpdateByExampleWithoutBLOBsMethodGenerator.java │ │ │ │ └── ProviderUpdateByPrimaryKeySelectiveMethodGenerator.java │ │ │ ├── model │ │ │ ├── BaseRecordGenerator.java │ │ │ ├── ExampleGenerator.java │ │ │ ├── PrimaryKeyGenerator.java │ │ │ ├── RecordWithBLOBsGenerator.java │ │ │ └── SimpleModelGenerator.java │ │ │ └── xmlmapper │ │ │ ├── MixedMapperGenerator.java │ │ │ ├── SimpleXMLMapperGenerator.java │ │ │ ├── XMLMapperGenerator.java │ │ │ └── elements │ │ │ ├── AbstractXmlElementGenerator.java │ │ │ ├── BaseColumnListElementGenerator.java │ │ │ ├── BatchInsertElementGenerator.java │ │ │ ├── BatchUpdateElementGenerator.java │ │ │ ├── BatchUpdateSelectiveElementGenerator.java │ │ │ ├── BlobColumnListElementGenerator.java │ │ │ ├── CountByExampleElementGenerator.java │ │ │ ├── DeleteByExampleElementGenerator.java │ │ │ ├── DeleteByPrimaryKeyElementGenerator.java │ │ │ ├── ExampleWhereClauseElementGenerator.java │ │ │ ├── InsertElementGenerator.java │ │ │ ├── InsertSelectiveElementGenerator.java │ │ │ ├── ResultMapWithBLOBsElementGenerator.java │ │ │ ├── ResultMapWithoutBLOBsElementGenerator.java │ │ │ ├── SelectByExampleWithBLOBsElementGenerator.java │ │ │ ├── SelectByExampleWithoutBLOBsElementGenerator.java │ │ │ ├── SelectByPrimaryKeyElementGenerator.java │ │ │ ├── SelectFirstByExampleElementGenerator.java │ │ │ ├── SimpleSelectAllElementGenerator.java │ │ │ ├── SimpleSelectByPrimaryKeyElementGenerator.java │ │ │ ├── UpdateByExampleSelectiveElementGenerator.java │ │ │ ├── UpdateByExampleWithBLOBsElementGenerator.java │ │ │ ├── UpdateByExampleWithoutBLOBsElementGenerator.java │ │ │ ├── UpdateByPrimaryKeySelectiveElementGenerator.java │ │ │ ├── UpdateByPrimaryKeyWithBLOBsElementGenerator.java │ │ │ └── UpdateByPrimaryKeyWithoutBLOBsElementGenerator.java │ │ ├── config │ │ ├── ColumnOverride.java │ │ ├── ColumnRenamingRule.java │ │ ├── CommentGeneratorConfiguration.java │ │ ├── Configuration.java │ │ ├── ConnectionFactoryConfiguration.java │ │ ├── Context.java │ │ ├── DomainObjectRenamingRule.java │ │ ├── GeneratedKey.java │ │ ├── IgnoredColumn.java │ │ ├── IgnoredColumnException.java │ │ ├── IgnoredColumnPattern.java │ │ ├── JDBCConnectionConfiguration.java │ │ ├── JavaClientGeneratorConfiguration.java │ │ ├── JavaModelGeneratorConfiguration.java │ │ ├── JavaTypeResolverConfiguration.java │ │ ├── MergeConstants.java │ │ ├── ModelType.java │ │ ├── PluginConfiguration.java │ │ ├── PropertyHolder.java │ │ ├── PropertyRegistry.java │ │ ├── SqlMapGeneratorConfiguration.java │ │ ├── TableConfiguration.java │ │ ├── TypedPropertyHolder.java │ │ └── xml │ │ │ ├── ConfigurationParser.java │ │ │ ├── MyBatisGeneratorConfigurationParser.java │ │ │ ├── ParserEntityResolver.java │ │ │ ├── ParserErrorHandler.java │ │ │ └── mybatis-generator-config_1_0.dtd │ │ ├── exception │ │ ├── InvalidConfigurationException.java │ │ ├── MultiMessageException.java │ │ ├── ShellException.java │ │ └── XMLParserException.java │ │ ├── internal │ │ ├── DefaultCommentGenerator.java │ │ ├── DefaultShellCallback.java │ │ ├── DomWriter.java │ │ ├── JDBCConnectionFactory.java │ │ ├── NullProgressCallback.java │ │ ├── ObjectFactory.java │ │ ├── PluginAggregator.java │ │ ├── XmlFileMergerJaxp.java │ │ ├── db │ │ │ ├── ActualTableName.java │ │ │ ├── DatabaseDialects.java │ │ │ ├── DatabaseIntrospector.java │ │ │ └── SqlReservedWords.java │ │ ├── rules │ │ │ ├── BaseRules.java │ │ │ ├── ConditionalModelRules.java │ │ │ ├── FlatModelRules.java │ │ │ ├── HierarchicalModelRules.java │ │ │ ├── Rules.java │ │ │ └── RulesDelegate.java │ │ ├── types │ │ │ └── JavaTypeResolverDefaultImpl.java │ │ └── util │ │ │ ├── ClassloaderUtility.java │ │ │ ├── CustomCollectors.java │ │ │ ├── EqualsUtil.java │ │ │ ├── HashCodeUtil.java │ │ │ ├── JavaBeansUtil.java │ │ │ ├── StringUtility.java │ │ │ └── messages │ │ │ ├── Messages.java │ │ │ └── messages.properties │ │ ├── logging │ │ ├── AbstractLogFactory.java │ │ ├── Log.java │ │ ├── LogException.java │ │ ├── LogFactory.java │ │ ├── commons │ │ │ ├── JakartaCommonsLoggingImpl.java │ │ │ └── JakartaCommonsLoggingLogFactory.java │ │ ├── jdk14 │ │ │ ├── Jdk14LoggingImpl.java │ │ │ └── Jdk14LoggingLogFactory.java │ │ ├── log4j │ │ │ ├── Log4jImpl.java │ │ │ └── Log4jLoggingLogFactory.java │ │ ├── log4j2 │ │ │ ├── Log4j2AbstractLoggerImpl.java │ │ │ ├── Log4j2Impl.java │ │ │ ├── Log4j2LoggerImpl.java │ │ │ └── Log4j2LoggingLogFactory.java │ │ ├── nologging │ │ │ ├── NoLoggingImpl.java │ │ │ └── NoLoggingLogFactory.java │ │ └── slf4j │ │ │ ├── Slf4jImpl.java │ │ │ ├── Slf4jLocationAwareLoggerImpl.java │ │ │ ├── Slf4jLoggerImpl.java │ │ │ └── Slf4jLoggingLogFactory.java │ │ ├── plugins │ │ ├── CachePlugin.java │ │ ├── CaseInsensitiveLikePlugin.java │ │ ├── EqualsHashCodePlugin.java │ │ ├── FluentBuilderMethodsPlugin.java │ │ ├── MapperAnnotationPlugin.java │ │ ├── MapperConfigPlugin.java │ │ ├── RenameExampleClassPlugin.java │ │ ├── RowBoundsPlugin.java │ │ ├── SerializablePlugin.java │ │ ├── ToStringPlugin.java │ │ ├── UnmergeableXmlMappersPlugin.java │ │ ├── VirtualPrimaryKeyPlugin.java │ │ └── dsql │ │ │ ├── DisableDeletePlugin.java │ │ │ ├── DisableInsertPlugin.java │ │ │ ├── DisableUpdatePlugin.java │ │ │ └── ReadOnlyPlugin.java │ │ └── runtime │ │ ├── dynamic │ │ └── sql │ │ │ ├── AbstractDynamicSqlMapperGenerator.java │ │ │ ├── DynamicSqlMapperGeneratorV1.java │ │ │ ├── DynamicSqlMapperGeneratorV2.java │ │ │ ├── DynamicSqlModelGenerator.java │ │ │ ├── DynamicSqlSupportClassGenerator.java │ │ │ ├── IntrospectedTableMyBatis3DynamicSqlImplV1.java │ │ │ ├── IntrospectedTableMyBatis3DynamicSqlImplV2.java │ │ │ └── elements │ │ │ ├── AbstractMethodGenerator.java │ │ │ ├── FieldAndImports.java │ │ │ ├── FragmentGenerator.java │ │ │ ├── MethodAndImports.java │ │ │ ├── MethodParts.java │ │ │ ├── v1 │ │ │ ├── BasicCountMethodGenerator.java │ │ │ ├── BasicDeleteMethodGenerator.java │ │ │ ├── BasicInsertMethodGenerator.java │ │ │ ├── BasicSelectManyMethodGenerator.java │ │ │ ├── BasicSelectOneMethodGenerator.java │ │ │ ├── BasicUpdateMethodGenerator.java │ │ │ ├── CountByExampleMethodGenerator.java │ │ │ ├── DeleteByExampleMethodGenerator.java │ │ │ ├── DeleteByPrimaryKeyMethodGenerator.java │ │ │ ├── InsertMethodGenerator.java │ │ │ ├── InsertSelectiveMethodGenerator.java │ │ │ ├── SelectByExampleMethodGenerator.java │ │ │ ├── SelectByPrimaryKeyMethodGenerator.java │ │ │ ├── SelectDistinctByExampleMethodGenerator.java │ │ │ ├── UpdateByExampleMethodGenerator.java │ │ │ ├── UpdateByExampleSelectiveMethodGenerator.java │ │ │ ├── UpdateByPrimaryKeyMethodGenerator.java │ │ │ └── UpdateByPrimaryKeySelectiveMethodGenerator.java │ │ │ └── v2 │ │ │ ├── BasicCountMethodGenerator.java │ │ │ ├── BasicDeleteMethodGenerator.java │ │ │ ├── BasicInsertMethodGenerator.java │ │ │ ├── BasicMultipleInsertHelperMethodGenerator.java │ │ │ ├── BasicMultipleInsertMethodGenerator.java │ │ │ ├── BasicSelectManyMethodGenerator.java │ │ │ ├── BasicSelectOneMethodGeneratorV2.java │ │ │ ├── BasicUpdateMethodGenerator.java │ │ │ ├── DeleteByPrimaryKeyMethodGeneratorV2.java │ │ │ ├── GeneralCountMethodGenerator.java │ │ │ ├── GeneralDeleteMethodGenerator.java │ │ │ ├── GeneralSelectDistinctMethodGenerator.java │ │ │ ├── GeneralSelectMethodGenerator.java │ │ │ ├── GeneralSelectOneMethodGenerator.java │ │ │ ├── GeneralUpdateMethodGenerator.java │ │ │ ├── InsertMethodGeneratorV2.java │ │ │ ├── InsertMultipleMethodGenerator.java │ │ │ ├── InsertSelectiveMethodGeneratorV2.java │ │ │ ├── SelectByPrimaryKeyMethodGeneratorV2.java │ │ │ ├── SelectListGenerator.java │ │ │ ├── UpdateAllColumnsMethodGenerator.java │ │ │ ├── UpdateByPrimaryKeyMethodGeneratorV2.java │ │ │ ├── UpdateByPrimaryKeySelectiveMethodGeneratorV2.java │ │ │ ├── UpdateSelectiveColumnsMethodGenerator.java │ │ │ └── Utils.java │ │ └── kotlin │ │ ├── IntrospectedTableKotlinImpl.java │ │ ├── KotlinDataClassGenerator.java │ │ ├── KotlinDynamicSqlSupportClassGenerator.java │ │ ├── KotlinMapperAndExtensionsGenerator.java │ │ └── elements │ │ ├── AbstractKotlinFunctionGenerator.java │ │ ├── BasicCountMethodGenerator.java │ │ ├── BasicDeleteMethodGenerator.java │ │ ├── BasicInsertMethodGenerator.java │ │ ├── BasicMultipleInsertHelperMethodGenerator.java │ │ ├── BasicMultipleInsertMethodGenerator.java │ │ ├── BasicSelectManyMethodGenerator.java │ │ ├── BasicSelectOneMethodGenerator.java │ │ ├── BasicUpdateMethodGenerator.java │ │ ├── ColumnListGenerator.java │ │ ├── DeleteByPrimaryKeyMethodGenerator.java │ │ ├── GeneralCountMethodGenerator.java │ │ ├── GeneralDeleteMethodGenerator.java │ │ ├── GeneralSelectDistinctMethodGenerator.java │ │ ├── GeneralSelectMethodGenerator.java │ │ ├── GeneralSelectOneMethodGenerator.java │ │ ├── GeneralUpdateMethodGenerator.java │ │ ├── InsertMethodGenerator.java │ │ ├── InsertMultipleMethodGenerator.java │ │ ├── InsertMultipleVarargMethodGenerator.java │ │ ├── InsertSelectiveMethodGenerator.java │ │ ├── KotlinFragmentGenerator.java │ │ ├── KotlinFunctionAndImports.java │ │ ├── KotlinFunctionParts.java │ │ ├── KotlinPropertyAndImports.java │ │ ├── SelectByPrimaryKeyMethodGenerator.java │ │ ├── UpdateAllColumnsMethodGenerator.java │ │ ├── UpdateByPrimaryKeyMethodGenerator.java │ │ ├── UpdateByPrimaryKeySelectiveMethodGenerator.java │ │ └── UpdateSelectiveColumnsMethodGenerator.java │ └── resources │ └── org │ └── mybatis │ └── generator │ ├── config │ └── xml │ │ └── mybatis-generator-config_1_0.dtd │ └── internal │ └── util │ └── messages │ └── messages.properties ├── mybatis-generator-gui ├── .gitignore ├── README.md ├── _config.yml ├── package │ ├── macosx │ │ └── mybatis-generator-gui.icns │ └── windows │ │ └── mybatis-generator-gui.ico ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── zzg │ │ │ └── mybatis │ │ │ └── generator │ │ │ ├── App.java │ │ │ ├── MainUI.java │ │ │ ├── bridge │ │ │ └── MybatisGeneratorBridge.java │ │ │ ├── controller │ │ │ ├── BaseFXController.java │ │ │ ├── DbConnectionController.java │ │ │ ├── FXMLPage.java │ │ │ ├── GeneratorConfigController.java │ │ │ ├── MainUIController.java │ │ │ ├── OverSshController.java │ │ │ ├── PictureProcessStateController.java │ │ │ ├── SelectTableColumnController.java │ │ │ └── TabPaneController.java │ │ │ ├── exception │ │ │ └── DbDriverLoadingException.java │ │ │ ├── model │ │ │ ├── CachedFXMLLoader.java │ │ │ ├── DatabaseConfig.java │ │ │ ├── DatabaseDTO.java │ │ │ ├── DbType.java │ │ │ ├── GeneratorConfig.java │ │ │ └── UITableColumnVO.java │ │ │ ├── plugins │ │ │ ├── CommonDAOInterfacePlugin.java │ │ │ ├── CustomBatchPlugin.java │ │ │ ├── DbRemarksCommentGenerator.java │ │ │ ├── JavaTypeResolverJsr310Impl.java │ │ │ ├── MySQLForUpdatePlugin.java │ │ │ ├── MySQLLimitPlugin.java │ │ │ └── RepositoryPlugin.java │ │ │ ├── util │ │ │ ├── ConfigHelper.java │ │ │ ├── ConnectionManager.java │ │ │ ├── DbUtil.java │ │ │ └── MyStringUtils.java │ │ │ └── view │ │ │ ├── AlertUtil.java │ │ │ ├── LeftDbTreeCell.java │ │ │ └── UIProgressCallback.java │ └── resources │ │ ├── fxml │ │ ├── MainUI.fxml │ │ ├── basicConnection.fxml │ │ ├── generatorConfigs.fxml │ │ ├── newConnection.fxml │ │ ├── selectTableColumn.fxml │ │ └── sshBasedConnection.fxml │ │ ├── icons │ │ ├── SSH_tunnel.png │ │ ├── SSH_tunnel_disconnected.png │ │ ├── computer.png │ │ ├── config-list.png │ │ ├── database.png │ │ ├── mybatis-logo.png │ │ └── table.png │ │ ├── lib │ │ ├── mysql-connector-java-5.1.38.jar │ │ ├── mysql-connector-java-8.0.11.jar │ │ ├── ojdbc6.jar │ │ ├── postgresql-9.4.1209.jar │ │ ├── sqlite-jdbc-3.19.3.jar │ │ └── sqljdbc4-4.0.jar │ │ ├── logback.xml │ │ ├── sqlite3.db │ │ └── style.css │ └── test │ └── java │ └── com │ └── zzg │ └── mybatis │ └── generator │ └── util │ ├── ConfigHelperTest.java │ └── StringUtilTest.java ├── pom.xml └── src └── main └── resources └── lib ├── mysql-connector-java-5.1.38.jar ├── mysql-connector-java-8.0.11.jar ├── ojdbc6.jar ├── postgresql-9.4.1209.jar ├── sqlite-jdbc-3.19.3.jar └── sqljdbc4-4.0.jar /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled class file 2 | *.class 3 | 4 | # Log file 5 | *.log 6 | 7 | # BlueJ files 8 | *.ctxt 9 | 10 | # Mobile Tools for Java (J2ME) 11 | .mtj.tmp/ 12 | 13 | # Package Files # 14 | #*.jar 15 | *.war 16 | *.nar 17 | *.ear 18 | *.zip 19 | *.tar.gz 20 | *.rar 21 | 22 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 23 | hs_err_pid* 24 | 25 | #idea 26 | .idea/ 27 | #target 28 | .target/ 29 | /*/target/ 30 | target/ 31 | /.project 32 | /.gitignore 33 | 34 | 35 | *.iml 36 | .settings/ 37 | .project 38 | .classpath 39 | /config -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | mybatis-generator-gui-plus 2 | ============== 3 | 4 | mybatis-generator-gui-plus是基于 [mybatis generator-gui](https://github.com/zouzg/mybatis-generator-gui) 扩展的工具,区别在于功能上的扩展了批量操作的方法,其他几乎没有差别。 5 | 6 | 增加的方法说明: 7 | 8 | 批量更新 batchUpdate 9 | 10 | 批量可选更新 batchUpdateSelective 11 | 12 | 批量插入 batchInsert 13 | 14 | 条件查询返回一个 selectFirstByExample 15 | 16 | ![image](https://user-images.githubusercontent.com/3505708/49334784-1a42c980-f619-11e8-914d-9ea85db9cec3.png) 17 | 18 | 19 | ![basic](https://user-images.githubusercontent.com/3505708/51911610-45754980-240d-11e9-85ad-643e55cafab2.png) 20 | 21 | 22 | ![overSSH](https://user-images.githubusercontent.com/3505708/51911646-5920b000-240d-11e9-9048-738306a56d14.png) 23 | 24 | ### 核心特性 25 | * 按照界面步骤轻松生成代码,省去XML繁琐的学习与配置过程 26 | * 保存数据库连接与Generator配置,每次代码生成轻松搞定 27 | * 内置常用插件,比如分页插件 28 | * 支持OverSSH 方式,通过SSH隧道连接至公司内网访问数据库 29 | * 把数据库中表列的注释生成为Java实体的注释,生成的实体清晰明了 30 | * 可选的去除掉对版本管理不友好的注释,这样新增或删除字段重新生成的文件比较过来清楚 31 | * 目前已经支持Mysql、Mysql8、Oracle、PostgreSQL与SQL Server,暂不对其他非主流数据库提供支持。(MySQL支持的比较好,其他数据库有什么问题可以在issue中反馈) 32 | 33 | ### 要求 34 | 本工具由于使用了JavaFX 特性,需要JDK 1.8及以上版本,支持 OracleJDK、OpenJDK。 35 | 36 | ### 下载 37 | 推荐使用 Git 工具克隆项目到本地。 38 | 39 | 40 | ### 启动本软件 41 | 42 | * 方法一:IDE中运行 43 | 44 | 在 Eclipse 或 IntelliJ IDEA 中打开项目,该项目下依赖两个模块,其中一个 `mybatis-generator-core` 未建立关联,需要手动导入 `mybatis-generator-core` 的 pom 文件,在`mybatis-generator-gui`模块下找到`com.zzg.mybatis.generator.MainUI`类并运行就可以了(检查你的IED运行的jdk版本是否符合要求)。 45 | 46 | * 其他方法: 可参考原项目中的其他方式,其他方式本项目均为测试过是否可用,不保证可以启动。推荐在IDE中启动。 47 | 48 | 49 | ### 注意事项 50 | * 本自动生成代码工具只适合生成单表的增删改查,对于需要做数据库联合查询的,请自行写新的XML与Mapper; 51 | * 部分系统在中文输入方法时输入框中无法输入文字,请切换成英文输入法; 52 | * 如果不明白对应字段或选项是什么意思的时候,把光标放在对应字段或Label上停留一会然后如果有解释会出现解释; 53 | 54 | 55 | ### 贡献 56 | 目前本工具只是本人项目人使用到了并且觉得非常有用所以把它开源,如果你觉得有用并且想改进本软件,你可以: 57 | * 对于你认为有用的功能,你可以在Issue提,我可以开发的尽量满足 58 | * 对于有Bug的地方,请按如下方式在Issue中提bug 59 | * 如何重现你的bug,包括你使用的系统,JDK版本,数据库类型及版本 60 | * 如果有任何的错误截图会更好 61 | * 如果你是一些常见的数据库连接、软件启动不了等问题,请先仔细阅读上面的文档(问问题的时候尽量把各种信息都提供好,否则只是几行文字是没有人愿意为你解答的)。 62 | 63 | - - - 64 | Licensed under the Apache 2.0 License 65 | 66 | Copyright 2020 by derotyoung 67 | -------------------------------------------------------------------------------- /mybatis-generator-core/pom.properties: -------------------------------------------------------------------------------- 1 | #Created by Apache Maven 3.6.5 2 | version=1.4.0 3 | groupId=org.mybatis.generator 4 | artifactId=mybatis-generator-core -------------------------------------------------------------------------------- /mybatis-generator-core/src/main/assembly/src.xml: -------------------------------------------------------------------------------- 1 | 13 | 16 | bundle 17 | 18 | zip 19 | 20 | 21 | 22 | 23 | ${project.basedir}/README* 24 | ${project.basedir}/LICENSE* 25 | ${project.basedir}/NOTICE* 26 | 27 | 28 | 29 | ${project.build.directory} 30 | lib 31 | 32 | *.jar 33 | 34 | 35 | 36 | ${project.build.directory}/site 37 | docs 38 | 39 | **/*.* 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /mybatis-generator-core/src/main/java/org/mybatis/generator/ant/AntProgressCallback.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2006-2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.mybatis.generator.ant; 17 | 18 | import org.apache.tools.ant.Project; 19 | import org.apache.tools.ant.Task; 20 | import org.mybatis.generator.internal.NullProgressCallback; 21 | 22 | /** 23 | * This callback logs progress messages with the Ant logger. 24 | * 25 | * @author Jeff Butler 26 | */ 27 | public class AntProgressCallback extends NullProgressCallback { 28 | 29 | /** The task. */ 30 | private Task task; 31 | 32 | /** The verbose. */ 33 | private boolean verbose; 34 | 35 | /** 36 | * Instantiates a new ant progress callback. 37 | * 38 | * @param task 39 | * the task 40 | * @param verbose 41 | * the verbose 42 | */ 43 | public AntProgressCallback(Task task, boolean verbose) { 44 | super(); 45 | this.task = task; 46 | this.verbose = verbose; 47 | } 48 | 49 | /* (non-Javadoc) 50 | * @see org.mybatis.generator.internal.NullProgressCallback#startTask(java.lang.String) 51 | */ 52 | @Override 53 | public void startTask(String subTaskName) { 54 | if (verbose) { 55 | task.log(subTaskName, Project.MSG_VERBOSE); 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /mybatis-generator-core/src/main/java/org/mybatis/generator/api/ConnectionFactory.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2006-2017 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.mybatis.generator.api; 17 | 18 | import java.sql.Connection; 19 | import java.sql.SQLException; 20 | import java.util.Properties; 21 | 22 | public interface ConnectionFactory { 23 | 24 | /** 25 | * Should return a connection to the database in use for this context. 26 | * The generator will call this method only one time for each context. 27 | * The generator will close the connection. 28 | * 29 | * @return the connection 30 | * @throws SQLException if there is some error obtaining the connection 31 | */ 32 | Connection getConnection() throws SQLException; 33 | 34 | /** 35 | * Adds properties for this instance from any properties configured in the 36 | * ConnectionFactory. 37 | * 38 | *

This method will be called before any of the get methods. 39 | * 40 | * @param properties 41 | * All properties from the configuration 42 | */ 43 | void addConfigurationProperties(Properties properties); 44 | } 45 | -------------------------------------------------------------------------------- /mybatis-generator-core/src/main/java/org/mybatis/generator/api/GeneratedKotlinFile.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2006-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.mybatis.generator.api; 17 | 18 | import org.mybatis.generator.api.dom.kotlin.KotlinFile; 19 | 20 | public class GeneratedKotlinFile extends GeneratedFile { 21 | 22 | private KotlinFile kotlinFile; 23 | 24 | private String fileEncoding; 25 | 26 | private KotlinFormatter kotlinFormatter; 27 | 28 | public GeneratedKotlinFile(KotlinFile kotlinFile, 29 | String targetProject, 30 | String fileEncoding, 31 | KotlinFormatter kotlinFormatter) { 32 | super(targetProject); 33 | this.kotlinFile = kotlinFile; 34 | this.fileEncoding = fileEncoding; 35 | this.kotlinFormatter = kotlinFormatter; 36 | } 37 | 38 | @Override 39 | public String getFormattedContent() { 40 | return kotlinFormatter.getFormattedContent(kotlinFile); 41 | } 42 | 43 | @Override 44 | public String getFileName() { 45 | return kotlinFile.getFileName(); 46 | } 47 | 48 | @Override 49 | public String getTargetPackage() { 50 | return kotlinFile.getPackage().orElse(""); //$NON-NLS-1$ 51 | } 52 | 53 | @Override 54 | public boolean isMergeable() { 55 | return false; 56 | } 57 | 58 | public String getFileEncoding() { 59 | return fileEncoding; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /mybatis-generator-core/src/main/java/org/mybatis/generator/api/GeneratedXmlFile.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2006-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.mybatis.generator.api; 17 | 18 | import org.mybatis.generator.api.dom.xml.Document; 19 | 20 | public class GeneratedXmlFile extends GeneratedFile { 21 | 22 | private Document document; 23 | 24 | private String fileName; 25 | 26 | private String targetPackage; 27 | 28 | private boolean isMergeable; 29 | 30 | private XmlFormatter xmlFormatter; 31 | 32 | public GeneratedXmlFile(Document document, String fileName, 33 | String targetPackage, String targetProject, boolean isMergeable, 34 | XmlFormatter xmlFormatter) { 35 | super(targetProject); 36 | this.document = document; 37 | this.fileName = fileName; 38 | this.targetPackage = targetPackage; 39 | this.isMergeable = isMergeable; 40 | this.xmlFormatter = xmlFormatter; 41 | } 42 | 43 | @Override 44 | public String getFormattedContent() { 45 | return xmlFormatter.getFormattedContent(document); 46 | } 47 | 48 | @Override 49 | public String getFileName() { 50 | return fileName; 51 | } 52 | 53 | @Override 54 | public String getTargetPackage() { 55 | return targetPackage; 56 | } 57 | 58 | @Override 59 | public boolean isMergeable() { 60 | return isMergeable; 61 | } 62 | 63 | public void setMergeable(boolean isMergeable) { 64 | this.isMergeable = isMergeable; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /mybatis-generator-core/src/main/java/org/mybatis/generator/api/JavaFormatter.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2006-2017 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.mybatis.generator.api; 17 | 18 | import org.mybatis.generator.api.dom.java.CompilationUnit; 19 | import org.mybatis.generator.config.Context; 20 | 21 | /** 22 | * Objects implementing this interface are used to convert the internal 23 | * representation of the Java DOM classes into a string suitable for 24 | * saving to the file system. Note that the string generated by this 25 | * class will be saved directly to the file system with no additional modifications. 26 | * 27 | *

Only one instance of the class will be created in each context. Configuration can 28 | * be passed into the class through the use of properties in the Context. 29 | * 30 | * @author Jeff Butler 31 | * 32 | */ 33 | public interface JavaFormatter { 34 | void setContext(Context context); 35 | 36 | String getFormattedContent(CompilationUnit compilationUnit); 37 | } 38 | -------------------------------------------------------------------------------- /mybatis-generator-core/src/main/java/org/mybatis/generator/api/KotlinFormatter.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2006-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.mybatis.generator.api; 17 | 18 | import org.mybatis.generator.api.dom.kotlin.KotlinFile; 19 | import org.mybatis.generator.config.Context; 20 | 21 | /** 22 | * Objects implementing this interface are used to convert the internal 23 | * representation of the Kotlin DOM classes into a string suitable for 24 | * saving to the file system. Note that the string generated by this 25 | * class will be saved directly to the file system with no additional modifications. 26 | * 27 | *

Only one instance of the class will be created in each context. Configuration can 28 | * be passed into the class through the use of properties in the Context. 29 | * 30 | * @author Jeff Butler 31 | * 32 | */ 33 | public interface KotlinFormatter { 34 | void setContext(Context context); 35 | 36 | String getFormattedContent(KotlinFile kotlinFile); 37 | } 38 | -------------------------------------------------------------------------------- /mybatis-generator-core/src/main/java/org/mybatis/generator/api/VerboseProgressCallback.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2006-2017 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.mybatis.generator.api; 17 | 18 | import org.mybatis.generator.internal.NullProgressCallback; 19 | 20 | /** 21 | * A slightly more verbose progress callback. 22 | * 23 | * @author Jeff Butler 24 | * 25 | */ 26 | public class VerboseProgressCallback extends NullProgressCallback { 27 | 28 | public VerboseProgressCallback() { 29 | super(); 30 | } 31 | 32 | @Override 33 | public void startTask(String taskName) { 34 | System.out.println(taskName); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /mybatis-generator-core/src/main/java/org/mybatis/generator/api/XmlFormatter.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2006-2017 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.mybatis.generator.api; 17 | 18 | import org.mybatis.generator.api.dom.xml.Document; 19 | import org.mybatis.generator.config.Context; 20 | 21 | /** 22 | * Objects implementing this interface are used to convert the internal 23 | * representation of the XML DOM classes into a string suitable for 24 | * saving to the file system. Note that the string generated by this 25 | * class will be saved directly to the file system with no additional modifications. 26 | * 27 | *

Only one instance of the class will be created in each context. Configuration can 28 | * be passed into the class through the use of properties in the Context. 29 | * 30 | * @author Jeff Butler 31 | * 32 | */ 33 | public interface XmlFormatter { 34 | void setContext(Context context); 35 | 36 | String getFormattedContent(Document document); 37 | } 38 | -------------------------------------------------------------------------------- /mybatis-generator-core/src/main/java/org/mybatis/generator/api/dom/DefaultKotlinFormatter.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2006-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.mybatis.generator.api.dom; 17 | 18 | import org.mybatis.generator.api.KotlinFormatter; 19 | import org.mybatis.generator.api.dom.kotlin.KotlinFile; 20 | import org.mybatis.generator.api.dom.kotlin.render.KotlinFileRenderer; 21 | import org.mybatis.generator.config.Context; 22 | 23 | /** 24 | * This class is the default formatter for generated Kotlin. This class will use the 25 | * built in DOM renderers. 26 | * 27 | * @author Jeff Butler 28 | * 29 | */ 30 | public class DefaultKotlinFormatter implements KotlinFormatter { 31 | protected Context context; 32 | 33 | @Override 34 | public String getFormattedContent(KotlinFile kotlinFile) { 35 | return new KotlinFileRenderer().render(kotlinFile); 36 | } 37 | 38 | @Override 39 | public void setContext(Context context) { 40 | this.context = context; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /mybatis-generator-core/src/main/java/org/mybatis/generator/api/dom/DefaultXmlFormatter.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2006-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.mybatis.generator.api.dom; 17 | 18 | import org.mybatis.generator.api.XmlFormatter; 19 | import org.mybatis.generator.api.dom.xml.Document; 20 | import org.mybatis.generator.api.dom.xml.render.DocumentRenderer; 21 | import org.mybatis.generator.config.Context; 22 | 23 | /** 24 | * This class is the default formatter for generated XML. This class will use the 25 | * built in document renderer. 26 | * 27 | * @author Jeff Butler 28 | * 29 | */ 30 | public class DefaultXmlFormatter implements XmlFormatter { 31 | protected Context context; 32 | 33 | @Override 34 | public String getFormattedContent(Document document) { 35 | return new DocumentRenderer().render(document); 36 | } 37 | 38 | @Override 39 | public void setContext(Context context) { 40 | this.context = context; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /mybatis-generator-core/src/main/java/org/mybatis/generator/api/dom/java/CompilationUnit.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2006-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.mybatis.generator.api.dom.java; 17 | 18 | import java.util.List; 19 | import java.util.Set; 20 | 21 | /** 22 | * This interface describes methods common to all Java compilation units (Java 23 | * classes, interfaces, and enums). 24 | * 25 | * @author Jeff Butler 26 | */ 27 | public interface CompilationUnit { 28 | 29 | Set getImportedTypes(); 30 | 31 | Set getStaticImports(); 32 | 33 | FullyQualifiedJavaType getType(); 34 | 35 | void addImportedType(FullyQualifiedJavaType importedType); 36 | 37 | void addImportedTypes(Set importedTypes); 38 | 39 | void addStaticImport(String staticImport); 40 | 41 | void addStaticImports(Set staticImports); 42 | 43 | /** 44 | * Comments will be written at the top of the file as is, we do not append any start or end comment characters. 45 | * 46 | *

Note that in the Eclipse plugin, file comments will not be merged. 47 | * 48 | * @param commentLine 49 | * the comment line 50 | */ 51 | void addFileCommentLine(String commentLine); 52 | 53 | List getFileCommentLines(); 54 | 55 | R accept(CompilationUnitVisitor visitor); 56 | } 57 | -------------------------------------------------------------------------------- /mybatis-generator-core/src/main/java/org/mybatis/generator/api/dom/java/CompilationUnitVisitor.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2006-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.mybatis.generator.api.dom.java; 17 | 18 | public interface CompilationUnitVisitor { 19 | R visit(TopLevelClass topLevelClass); 20 | 21 | R visit(TopLevelEnumeration topLevelEnumeration); 22 | 23 | R visit(Interface topLevelInterface); 24 | } 25 | -------------------------------------------------------------------------------- /mybatis-generator-core/src/main/java/org/mybatis/generator/api/dom/java/InitializationBlock.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2006-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.mybatis.generator.api.dom.java; 17 | 18 | import java.util.ArrayList; 19 | import java.util.Collection; 20 | import java.util.List; 21 | 22 | public class InitializationBlock { 23 | 24 | private boolean isStatic; 25 | private List bodyLines = new ArrayList<>(); 26 | private List javaDocLines = new ArrayList<>(); 27 | 28 | public InitializationBlock() { 29 | this(false); 30 | } 31 | 32 | public InitializationBlock(boolean isStatic) { 33 | this.isStatic = isStatic; 34 | } 35 | 36 | public boolean isStatic() { 37 | return isStatic; 38 | } 39 | 40 | public void setStatic(boolean isStatic) { 41 | this.isStatic = isStatic; 42 | } 43 | 44 | public List getBodyLines() { 45 | return bodyLines; 46 | } 47 | 48 | public void addBodyLine(String line) { 49 | bodyLines.add(line); 50 | } 51 | 52 | public void addBodyLine(int index, String line) { 53 | bodyLines.add(index, line); 54 | } 55 | 56 | public void addBodyLines(Collection lines) { 57 | bodyLines.addAll(lines); 58 | } 59 | 60 | public void addBodyLines(int index, Collection lines) { 61 | bodyLines.addAll(index, lines); 62 | } 63 | 64 | public List getJavaDocLines() { 65 | return javaDocLines; 66 | } 67 | 68 | public void addJavaDocLine(String javaDocLine) { 69 | javaDocLines.add(javaDocLine); 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /mybatis-generator-core/src/main/java/org/mybatis/generator/api/dom/java/InnerEnum.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2006-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.mybatis.generator.api.dom.java; 17 | 18 | import java.util.ArrayList; 19 | import java.util.List; 20 | 21 | /** 22 | * This class encapsulates the idea of an inner enum - it has methods that make 23 | * it easy to generate inner enum. 24 | * 25 | * @author Jeff Butler 26 | */ 27 | public class InnerEnum extends AbstractJavaType { 28 | 29 | private List enumConstants = new ArrayList<>(); 30 | 31 | private List initializationBlocks = new ArrayList<>(); 32 | 33 | public InnerEnum(FullyQualifiedJavaType type) { 34 | super(type); 35 | } 36 | 37 | public InnerEnum(String type) { 38 | super(type); 39 | } 40 | 41 | public List getEnumConstants() { 42 | return enumConstants; 43 | } 44 | 45 | public void addEnumConstant(String enumConstant) { 46 | enumConstants.add(enumConstant); 47 | } 48 | 49 | public List getInitializationBlocks() { 50 | return initializationBlocks; 51 | } 52 | 53 | public void addInitializationBlock(InitializationBlock initializationBlock) { 54 | initializationBlocks.add(initializationBlock); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /mybatis-generator-core/src/main/java/org/mybatis/generator/api/dom/java/InnerInterface.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2006-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.mybatis.generator.api.dom.java; 17 | 18 | import java.util.ArrayList; 19 | import java.util.List; 20 | 21 | public class InnerInterface extends AbstractJavaType { 22 | private List typeParameters = new ArrayList<>(); 23 | 24 | public InnerInterface(FullyQualifiedJavaType type) { 25 | super(type); 26 | } 27 | 28 | public InnerInterface(String type) { 29 | super(type); 30 | } 31 | 32 | public List getTypeParameters() { 33 | return this.typeParameters; 34 | } 35 | 36 | public void addTypeParameter(TypeParameter typeParameter) { 37 | this.typeParameters.add(typeParameter); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /mybatis-generator-core/src/main/java/org/mybatis/generator/api/dom/java/JavaVisibility.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2006-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.mybatis.generator.api.dom.java; 17 | 18 | /** 19 | * Typesafe enum of possible Java visibility settings. 20 | * 21 | * @author Jeff Butler 22 | */ 23 | public enum JavaVisibility { 24 | PUBLIC("public "), //$NON-NLS-1$ 25 | PRIVATE("private "), //$NON-NLS-1$ 26 | PROTECTED("protected "), //$NON-NLS-1$ 27 | DEFAULT(""); //$NON-NLS-1$ 28 | 29 | private String value; 30 | 31 | JavaVisibility(String value) { 32 | this.value = value; 33 | } 34 | 35 | public String getValue() { 36 | return value; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /mybatis-generator-core/src/main/java/org/mybatis/generator/api/dom/java/TypeParameter.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2006-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.mybatis.generator.api.dom.java; 17 | 18 | import java.util.ArrayList; 19 | import java.util.List; 20 | 21 | import org.mybatis.generator.api.dom.java.render.TypeParameterRenderer; 22 | 23 | public class TypeParameter { 24 | 25 | private String name; 26 | 27 | private List extendsTypes = new ArrayList<>(); 28 | 29 | public TypeParameter(String name) { 30 | super(); 31 | this.name = name; 32 | } 33 | 34 | public TypeParameter(String name, List extendsTypes) { 35 | super(); 36 | this.name = name; 37 | this.extendsTypes.addAll(extendsTypes); 38 | } 39 | 40 | public String getName() { 41 | return name; 42 | } 43 | 44 | public List getExtendsTypes() { 45 | return extendsTypes; 46 | } 47 | 48 | @Override 49 | public String toString() { 50 | return new TypeParameterRenderer().render(this, null); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /mybatis-generator-core/src/main/java/org/mybatis/generator/api/dom/java/render/InitializationBlockRenderer.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2006-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.mybatis.generator.api.dom.java.render; 17 | 18 | import java.util.ArrayList; 19 | import java.util.List; 20 | 21 | import org.mybatis.generator.api.dom.java.InitializationBlock; 22 | 23 | public class InitializationBlockRenderer { 24 | 25 | private BodyLineRenderer bodyLineRenderer = new BodyLineRenderer(); 26 | 27 | public List render(InitializationBlock initializationBlock) { 28 | List lines = new ArrayList<>(); 29 | 30 | lines.addAll(initializationBlock.getJavaDocLines()); 31 | lines.add(renderFirstLine(initializationBlock)); 32 | lines.addAll(bodyLineRenderer.render(initializationBlock.getBodyLines())); 33 | lines.add("}"); //$NON-NLS-1$ 34 | 35 | return lines; 36 | } 37 | 38 | private String renderFirstLine(InitializationBlock initializationBlock) { 39 | if (initializationBlock.isStatic()) { 40 | return "static {"; //$NON-NLS-1$ 41 | } else { 42 | return "{"; //$NON-NLS-1$ 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /mybatis-generator-core/src/main/java/org/mybatis/generator/api/dom/java/render/ParameterRenderer.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2006-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.mybatis.generator.api.dom.java.render; 17 | 18 | import org.mybatis.generator.api.dom.java.CompilationUnit; 19 | import org.mybatis.generator.api.dom.java.JavaDomUtils; 20 | import org.mybatis.generator.api.dom.java.Parameter; 21 | import org.mybatis.generator.internal.util.CustomCollectors; 22 | 23 | public class ParameterRenderer { 24 | 25 | public String render(Parameter parameter, CompilationUnit compilationUnit) { 26 | return renderAnnotations(parameter) 27 | + JavaDomUtils.calculateTypeName(compilationUnit, parameter.getType()) 28 | + " " //$NON-NLS-1$ 29 | + (parameter.isVarargs() ? "... " : "") //$NON-NLS-1$ //$NON-NLS-2$ 30 | + parameter.getName(); 31 | } 32 | 33 | // should return empty string if no annotations 34 | private String renderAnnotations(Parameter parameter) { 35 | return parameter.getAnnotations().stream() 36 | .collect(CustomCollectors.joining(" ", "", " ")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /mybatis-generator-core/src/main/java/org/mybatis/generator/api/dom/java/render/TopLevelClassRenderer.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2006-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.mybatis.generator.api.dom.java.render; 17 | 18 | import static org.mybatis.generator.api.dom.java.render.RenderingUtilities.renderImports; 19 | import static org.mybatis.generator.api.dom.java.render.RenderingUtilities.renderInnerClassNoIndent; 20 | import static org.mybatis.generator.api.dom.java.render.RenderingUtilities.renderPackage; 21 | import static org.mybatis.generator.api.dom.java.render.RenderingUtilities.renderStaticImports; 22 | 23 | import java.util.ArrayList; 24 | import java.util.List; 25 | import java.util.stream.Collectors; 26 | 27 | import org.mybatis.generator.api.dom.java.TopLevelClass; 28 | 29 | public class TopLevelClassRenderer { 30 | 31 | public String render(TopLevelClass topLevelClass) { 32 | List lines = new ArrayList<>(); 33 | 34 | lines.addAll(topLevelClass.getFileCommentLines()); 35 | lines.addAll(renderPackage(topLevelClass)); 36 | lines.addAll(renderStaticImports(topLevelClass)); 37 | lines.addAll(renderImports(topLevelClass)); 38 | lines.addAll(renderInnerClassNoIndent(topLevelClass, topLevelClass)); 39 | 40 | return lines.stream() 41 | .collect(Collectors.joining(System.getProperty("line.separator"))); //$NON-NLS-1$ 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /mybatis-generator-core/src/main/java/org/mybatis/generator/api/dom/java/render/TopLevelEnumerationRenderer.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2006-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.mybatis.generator.api.dom.java.render; 17 | 18 | import static org.mybatis.generator.api.dom.java.render.RenderingUtilities.renderImports; 19 | import static org.mybatis.generator.api.dom.java.render.RenderingUtilities.renderInnerEnumNoIndent; 20 | import static org.mybatis.generator.api.dom.java.render.RenderingUtilities.renderPackage; 21 | import static org.mybatis.generator.api.dom.java.render.RenderingUtilities.renderStaticImports; 22 | 23 | import java.util.ArrayList; 24 | import java.util.List; 25 | import java.util.stream.Collectors; 26 | 27 | import org.mybatis.generator.api.dom.java.TopLevelEnumeration; 28 | 29 | public class TopLevelEnumerationRenderer { 30 | 31 | public String render(TopLevelEnumeration topLevelEnumeration) { 32 | List lines = new ArrayList<>(); 33 | 34 | lines.addAll(topLevelEnumeration.getFileCommentLines()); 35 | lines.addAll(renderPackage(topLevelEnumeration)); 36 | lines.addAll(renderStaticImports(topLevelEnumeration)); 37 | lines.addAll(renderImports(topLevelEnumeration)); 38 | lines.addAll(renderInnerEnumNoIndent(topLevelEnumeration, topLevelEnumeration)); 39 | 40 | return lines.stream() 41 | .collect(Collectors.joining(System.getProperty("line.separator"))); //$NON-NLS-1$ 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /mybatis-generator-core/src/main/java/org/mybatis/generator/api/dom/java/render/TopLevelInterfaceRenderer.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2006-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.mybatis.generator.api.dom.java.render; 17 | 18 | import static org.mybatis.generator.api.dom.java.render.RenderingUtilities.renderImports; 19 | import static org.mybatis.generator.api.dom.java.render.RenderingUtilities.renderInnerInterfaceNoIndent; 20 | import static org.mybatis.generator.api.dom.java.render.RenderingUtilities.renderPackage; 21 | import static org.mybatis.generator.api.dom.java.render.RenderingUtilities.renderStaticImports; 22 | 23 | import java.util.ArrayList; 24 | import java.util.List; 25 | import java.util.stream.Collectors; 26 | 27 | import org.mybatis.generator.api.dom.java.Interface; 28 | 29 | public class TopLevelInterfaceRenderer { 30 | 31 | public String render(Interface topLevelInterface) { 32 | List lines = new ArrayList<>(); 33 | 34 | lines.addAll(topLevelInterface.getFileCommentLines()); 35 | lines.addAll(renderPackage(topLevelInterface)); 36 | lines.addAll(renderStaticImports(topLevelInterface)); 37 | lines.addAll(renderImports(topLevelInterface)); 38 | lines.addAll(renderInnerInterfaceNoIndent(topLevelInterface, topLevelInterface)); 39 | 40 | return lines.stream() 41 | .collect(Collectors.joining(System.getProperty("line.separator"))); //$NON-NLS-1$ 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /mybatis-generator-core/src/main/java/org/mybatis/generator/api/dom/java/render/TypeParameterRenderer.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2006-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.mybatis.generator.api.dom.java.render; 17 | 18 | import org.mybatis.generator.api.dom.java.CompilationUnit; 19 | import org.mybatis.generator.api.dom.java.JavaDomUtils; 20 | import org.mybatis.generator.api.dom.java.TypeParameter; 21 | import org.mybatis.generator.internal.util.CustomCollectors; 22 | 23 | public class TypeParameterRenderer { 24 | public String render(TypeParameter typeParameter, CompilationUnit compilationUnit) { 25 | return typeParameter.getName() + typeParameter.getExtendsTypes().stream() 26 | .map(t -> JavaDomUtils.calculateTypeName(compilationUnit, t)) 27 | .collect(CustomCollectors.joining(" & ", " extends ", "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /mybatis-generator-core/src/main/java/org/mybatis/generator/api/dom/kotlin/KotlinModifier.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2006-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.mybatis.generator.api.dom.kotlin; 17 | 18 | public enum KotlinModifier { 19 | 20 | PUBLIC("public"), //$NON-NLS-1$ 21 | PRIVATE("private"), //$NON-NLS-1$ 22 | DATA("data"), //$NON-NLS-1$ 23 | LATE_INIT("lateinit"); //$NON-NLS-1$ 24 | 25 | private String value; 26 | 27 | KotlinModifier(String value) { 28 | this.value = value; 29 | } 30 | 31 | public String getValue() { 32 | return value; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /mybatis-generator-core/src/main/java/org/mybatis/generator/api/dom/kotlin/KotlinNamedItemContainer.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2006-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.mybatis.generator.api.dom.kotlin; 17 | 18 | import java.util.ArrayList; 19 | import java.util.List; 20 | 21 | public abstract class KotlinNamedItemContainer extends KotlinNamedItem { 22 | private List namedItems = new ArrayList<>(); 23 | 24 | public KotlinNamedItemContainer(NamedItemContainerBuilder builder) { 25 | super(builder); 26 | namedItems.addAll(builder.namedItems); 27 | } 28 | 29 | public void addNamedItem(KotlinNamedItem namedItem) { 30 | namedItems.add(namedItem); 31 | } 32 | 33 | public List getNamedItems() { 34 | return namedItems; 35 | } 36 | 37 | public abstract static class NamedItemContainerBuilder> 38 | extends AbstractBuilder { 39 | 40 | private List namedItems = new ArrayList<>(); 41 | 42 | protected NamedItemContainerBuilder(String name) { 43 | super(name); 44 | } 45 | 46 | public T withNamedItem(KotlinNamedItem namedItem) { 47 | namedItems.add(namedItem); 48 | return getThis(); 49 | } 50 | 51 | protected abstract T getThis(); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /mybatis-generator-core/src/main/java/org/mybatis/generator/api/dom/kotlin/KotlinNamedItemVisitor.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2006-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.mybatis.generator.api.dom.kotlin; 17 | 18 | public interface KotlinNamedItemVisitor { 19 | 20 | R visit(KotlinType kotlinType); 21 | 22 | R visit(KotlinProperty kotlinProperty); 23 | 24 | R visit(KotlinFunction kotlinFunction); 25 | } 26 | -------------------------------------------------------------------------------- /mybatis-generator-core/src/main/java/org/mybatis/generator/api/dom/kotlin/render/KotlinArgRenderer.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2006-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.mybatis.generator.api.dom.kotlin.render; 17 | 18 | import org.mybatis.generator.api.dom.kotlin.KotlinArg; 19 | import org.mybatis.generator.internal.util.CustomCollectors; 20 | 21 | public class KotlinArgRenderer { 22 | public String render(KotlinArg kotlinArg) { 23 | return renderAnnotations(kotlinArg) 24 | + kotlinArg.getName() 25 | + kotlinArg.getDataType().map(dt -> ": " + dt).orElse("") //$NON-NLS-1$ //$NON-NLS-2$ 26 | + kotlinArg.getInitializationString().map(s -> " = " + s).orElse(""); //$NON-NLS-1$ //$NON-NLS-2$ 27 | } 28 | 29 | private String renderAnnotations(KotlinArg kotlinArg) { 30 | return kotlinArg.getAnnotations().stream() 31 | .collect(CustomCollectors.joining(" ", "", " ")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /mybatis-generator-core/src/main/java/org/mybatis/generator/api/dom/kotlin/render/KotlinNamedItemRenderer.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2006-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.mybatis.generator.api.dom.kotlin.render; 17 | 18 | import java.util.List; 19 | 20 | import org.mybatis.generator.api.dom.kotlin.KotlinFunction; 21 | import org.mybatis.generator.api.dom.kotlin.KotlinNamedItem; 22 | import org.mybatis.generator.api.dom.kotlin.KotlinNamedItemVisitor; 23 | import org.mybatis.generator.api.dom.kotlin.KotlinProperty; 24 | import org.mybatis.generator.api.dom.kotlin.KotlinType; 25 | 26 | public class KotlinNamedItemRenderer implements KotlinNamedItemVisitor> { 27 | 28 | public List render(KotlinNamedItem namedItem) { 29 | return namedItem.accept(this); 30 | } 31 | 32 | @Override 33 | public List visit(KotlinType kotlinType) { 34 | return new KotlinTypeRenderer().render(kotlinType); 35 | } 36 | 37 | @Override 38 | public List visit(KotlinProperty kotlinProperty) { 39 | return new KotlinPropertyRenderer().render(kotlinProperty); 40 | } 41 | 42 | @Override 43 | public List visit(KotlinFunction kotlinFunction) { 44 | return new KotlinFunctionRenderer().render(kotlinFunction); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /mybatis-generator-core/src/main/java/org/mybatis/generator/api/dom/kotlin/render/KotlinPropertyRenderer.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2006-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.mybatis.generator.api.dom.kotlin.render; 17 | 18 | import java.util.ArrayList; 19 | import java.util.List; 20 | 21 | import org.mybatis.generator.api.dom.kotlin.KotlinProperty; 22 | 23 | public class KotlinPropertyRenderer { 24 | 25 | public List render(KotlinProperty kotlinProperty) { 26 | List answer = new ArrayList<>(); 27 | answer.addAll(kotlinProperty.getAnnotations()); 28 | answer.add(renderProperty(kotlinProperty)); 29 | return answer; 30 | } 31 | 32 | private String renderProperty(KotlinProperty kotlinProperty) { 33 | return KotlinRenderingUtilities.renderModifiers(kotlinProperty.getModifiers()) 34 | + kotlinProperty.getType().getValue() 35 | + " " //$NON-NLS-1$ 36 | + kotlinProperty.getName() 37 | + kotlinProperty.getDataType().map(dt -> ": " + dt).orElse("") //$NON-NLS-1$ //$NON-NLS-2$ 38 | + kotlinProperty.getInitializationString().map(s -> " = " + s).orElse(""); //$NON-NLS-1$ //$NON-NLS-2$ 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /mybatis-generator-core/src/main/java/org/mybatis/generator/api/dom/kotlin/render/KotlinRenderingUtilities.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2006-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.mybatis.generator.api.dom.kotlin.render; 17 | 18 | import java.util.List; 19 | 20 | import org.mybatis.generator.api.dom.kotlin.KotlinModifier; 21 | import org.mybatis.generator.internal.util.CustomCollectors; 22 | 23 | public class KotlinRenderingUtilities { 24 | 25 | private KotlinRenderingUtilities() {} 26 | 27 | public static final String KOTLIN_INDENT = " "; //$NON-NLS-1$ 28 | 29 | public static String renderModifiers(List modifiers) { 30 | return modifiers.stream().map(KotlinModifier::getValue) 31 | .collect(CustomCollectors.joining(" ", "", " ")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ 32 | } 33 | 34 | public static String kotlinIndent(String in) { 35 | if (in.isEmpty()) { 36 | return in; // don't indent empty lines 37 | } 38 | 39 | return KOTLIN_INDENT + in; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /mybatis-generator-core/src/main/java/org/mybatis/generator/api/dom/xml/Attribute.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2006-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.mybatis.generator.api.dom.xml; 17 | 18 | import java.util.Objects; 19 | 20 | public class Attribute { 21 | 22 | private String name; 23 | 24 | private String value; 25 | 26 | public Attribute(String name, String value) { 27 | this.name = Objects.requireNonNull(name); 28 | this.value = Objects.requireNonNull(value); 29 | } 30 | 31 | public String getName() { 32 | return name; 33 | } 34 | 35 | public String getValue() { 36 | return value; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /mybatis-generator-core/src/main/java/org/mybatis/generator/api/dom/xml/DocType.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2006-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.mybatis.generator.api.dom.xml; 17 | 18 | public interface DocType { 19 | R accept(DocTypeVisitor visitor); 20 | } 21 | -------------------------------------------------------------------------------- /mybatis-generator-core/src/main/java/org/mybatis/generator/api/dom/xml/DocTypeVisitor.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2006-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.mybatis.generator.api.dom.xml; 17 | 18 | public interface DocTypeVisitor { 19 | R visit(PublicDocType docType); 20 | 21 | R visit(SystemDocType docType); 22 | } 23 | -------------------------------------------------------------------------------- /mybatis-generator-core/src/main/java/org/mybatis/generator/api/dom/xml/Document.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2006-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.mybatis.generator.api.dom.xml; 17 | 18 | import java.util.Optional; 19 | 20 | public class Document { 21 | 22 | private DocType docType; 23 | 24 | private XmlElement rootElement; 25 | 26 | public Document(String publicId, String systemId) { 27 | docType = new PublicDocType(publicId, systemId); 28 | } 29 | 30 | public Document(String systemId) { 31 | docType = new SystemDocType(systemId); 32 | } 33 | 34 | public Document() { 35 | super(); 36 | } 37 | 38 | public XmlElement getRootElement() { 39 | return rootElement; 40 | } 41 | 42 | public void setRootElement(XmlElement rootElement) { 43 | this.rootElement = rootElement; 44 | } 45 | 46 | public Optional getDocType() { 47 | return Optional.ofNullable(docType); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /mybatis-generator-core/src/main/java/org/mybatis/generator/api/dom/xml/ElementVisitor.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2006-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.mybatis.generator.api.dom.xml; 17 | 18 | public interface ElementVisitor { 19 | R visit(TextElement element); 20 | 21 | R visit(XmlElement element); 22 | } 23 | -------------------------------------------------------------------------------- /mybatis-generator-core/src/main/java/org/mybatis/generator/api/dom/xml/PublicDocType.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2006-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.mybatis.generator.api.dom.xml; 17 | 18 | public class PublicDocType implements DocType { 19 | private String dtdLocation; 20 | private String dtdName; 21 | 22 | public PublicDocType(String dtdName, String dtdLocation) { 23 | super(); 24 | this.dtdName = dtdName; 25 | this.dtdLocation = dtdLocation; 26 | } 27 | 28 | public String getDtdLocation() { 29 | return dtdLocation; 30 | } 31 | 32 | public String getDtdName() { 33 | return dtdName; 34 | } 35 | 36 | @Override 37 | public R accept(DocTypeVisitor visitor) { 38 | return visitor.visit(this); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /mybatis-generator-core/src/main/java/org/mybatis/generator/api/dom/xml/SystemDocType.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2006-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.mybatis.generator.api.dom.xml; 17 | 18 | public class SystemDocType implements DocType { 19 | private String dtdLocation; 20 | 21 | public SystemDocType(String dtdLocation) { 22 | super(); 23 | this.dtdLocation = dtdLocation; 24 | } 25 | 26 | public String getDtdLocation() { 27 | return dtdLocation; 28 | } 29 | 30 | @Override 31 | public R accept(DocTypeVisitor visitor) { 32 | return visitor.visit(this); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /mybatis-generator-core/src/main/java/org/mybatis/generator/api/dom/xml/TextElement.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2006-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.mybatis.generator.api.dom.xml; 17 | 18 | public class TextElement implements VisitableElement { 19 | 20 | private String content; 21 | 22 | public TextElement(String content) { 23 | this.content = content; 24 | } 25 | 26 | public String getContent() { 27 | return content; 28 | } 29 | 30 | @Override 31 | public R accept(ElementVisitor visitor) { 32 | return visitor.visit(this); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /mybatis-generator-core/src/main/java/org/mybatis/generator/api/dom/xml/VisitableElement.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2006-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.mybatis.generator.api.dom.xml; 17 | 18 | @FunctionalInterface 19 | public interface VisitableElement { 20 | R accept(ElementVisitor visitor); 21 | } 22 | -------------------------------------------------------------------------------- /mybatis-generator-core/src/main/java/org/mybatis/generator/api/dom/xml/render/AttributeRenderer.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2006-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.mybatis.generator.api.dom.xml.render; 17 | 18 | import org.mybatis.generator.api.dom.xml.Attribute; 19 | 20 | public class AttributeRenderer { 21 | 22 | public String render(Attribute attribute) { 23 | return attribute.getName() 24 | + "=\"" //$NON-NLS-1$ 25 | + attribute.getValue() 26 | + "\""; //$NON-NLS-1$ 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /mybatis-generator-core/src/main/java/org/mybatis/generator/api/dom/xml/render/DocTypeRenderer.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2006-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.mybatis.generator.api.dom.xml.render; 17 | 18 | import org.mybatis.generator.api.dom.xml.DocTypeVisitor; 19 | import org.mybatis.generator.api.dom.xml.PublicDocType; 20 | import org.mybatis.generator.api.dom.xml.SystemDocType; 21 | 22 | public class DocTypeRenderer implements DocTypeVisitor { 23 | 24 | @Override 25 | public String visit(PublicDocType docType) { 26 | return "PUBLIC \"" //$NON-NLS-1$ 27 | + docType.getDtdName() 28 | + "\" \"" //$NON-NLS-1$ 29 | + docType.getDtdLocation() 30 | + "\""; //$NON-NLS-1$ 31 | } 32 | 33 | @Override 34 | public String visit(SystemDocType docType) { 35 | return "SYSTEM \"" //$NON-NLS-1$ 36 | + docType.getDtdLocation() 37 | + "\""; //$NON-NLS-1$ 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /mybatis-generator-core/src/main/java/org/mybatis/generator/api/dom/xml/render/DocumentRenderer.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2006-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.mybatis.generator.api.dom.xml.render; 17 | 18 | import java.util.function.Function; 19 | import java.util.stream.Collectors; 20 | import java.util.stream.Stream; 21 | 22 | import org.mybatis.generator.api.dom.xml.DocType; 23 | import org.mybatis.generator.api.dom.xml.Document; 24 | 25 | public class DocumentRenderer { 26 | 27 | public String render(Document document) { 28 | return Stream.of(renderXmlHeader(), 29 | renderDocType(document), 30 | renderRootElement(document)) 31 | .flatMap(Function.identity()) 32 | .collect(Collectors.joining(System.getProperty("line.separator"))); //$NON-NLS-1$ 33 | } 34 | 35 | private Stream renderXmlHeader() { 36 | return Stream.of(""); //$NON-NLS-1$ 37 | } 38 | 39 | private Stream renderDocType(Document document) { 40 | return Stream.of(""); //$NON-NLS-1$ 44 | } 45 | 46 | private String renderDocType(DocType docType) { 47 | return " " + docType.accept(new DocTypeRenderer()); //$NON-NLS-1$ 48 | } 49 | 50 | private Stream renderRootElement(Document document) { 51 | return document.getRootElement().accept(new ElementRenderer()); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /mybatis-generator-core/src/main/java/org/mybatis/generator/api/package.html: -------------------------------------------------------------------------------- 1 | 18 | 19 | 20 | 21 | Package Description for Main MyBatis Generator API Classes 22 | 23 | 24 |

Provides the main classes and interfaces used by clients of MyBatis Generator.

25 | 26 | 27 | -------------------------------------------------------------------------------- /mybatis-generator-core/src/main/java/org/mybatis/generator/codegen/AbstractGenerator.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2006-2017 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.mybatis.generator.codegen; 17 | 18 | import java.util.List; 19 | 20 | import org.mybatis.generator.api.IntrospectedTable; 21 | import org.mybatis.generator.api.ProgressCallback; 22 | import org.mybatis.generator.config.Context; 23 | 24 | public abstract class AbstractGenerator { 25 | protected Context context; 26 | protected IntrospectedTable introspectedTable; 27 | protected List warnings; 28 | protected ProgressCallback progressCallback; 29 | 30 | public AbstractGenerator() { 31 | super(); 32 | } 33 | 34 | public Context getContext() { 35 | return context; 36 | } 37 | 38 | public void setContext(Context context) { 39 | this.context = context; 40 | } 41 | 42 | public IntrospectedTable getIntrospectedTable() { 43 | return introspectedTable; 44 | } 45 | 46 | public void setIntrospectedTable(IntrospectedTable introspectedTable) { 47 | this.introspectedTable = introspectedTable; 48 | } 49 | 50 | public List getWarnings() { 51 | return warnings; 52 | } 53 | 54 | public void setWarnings(List warnings) { 55 | this.warnings = warnings; 56 | } 57 | 58 | public ProgressCallback getProgressCallback() { 59 | return progressCallback; 60 | } 61 | 62 | public void setProgressCallback(ProgressCallback progressCallback) { 63 | this.progressCallback = progressCallback; 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /mybatis-generator-core/src/main/java/org/mybatis/generator/codegen/AbstractJavaClientGenerator.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2006-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.mybatis.generator.codegen; 17 | 18 | /** 19 | * This class exists to that Java client generators can specify whether 20 | * an XML generator is required to match the methods in the 21 | * Java client. For example, a Java client built entirely with 22 | * annotations does not need matching XML. 23 | * 24 | * @author Jeff Butler 25 | * 26 | */ 27 | public abstract class AbstractJavaClientGenerator extends AbstractJavaGenerator { 28 | 29 | private boolean requiresXMLGenerator; 30 | 31 | public AbstractJavaClientGenerator(String project, boolean requiresXMLGenerator) { 32 | super(project); 33 | this.requiresXMLGenerator = requiresXMLGenerator; 34 | } 35 | 36 | /** 37 | * Returns true is a matching XML generator is required. 38 | * 39 | * @return true if matching XML is generator required 40 | */ 41 | public boolean requiresXMLGenerator() { 42 | return requiresXMLGenerator; 43 | } 44 | 45 | /** 46 | * Returns an instance of the XML generator associated 47 | * with this client generator. 48 | * 49 | * @return the matched XML generator. May return null if no 50 | * XML is required by this generator 51 | */ 52 | public abstract AbstractXmlGenerator getMatchedXMLGenerator(); 53 | } 54 | -------------------------------------------------------------------------------- /mybatis-generator-core/src/main/java/org/mybatis/generator/codegen/AbstractKotlinGenerator.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2006-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.mybatis.generator.codegen; 17 | 18 | import java.util.Arrays; 19 | import java.util.List; 20 | 21 | import org.mybatis.generator.api.dom.kotlin.KotlinFile; 22 | 23 | public abstract class AbstractKotlinGenerator extends AbstractGenerator { 24 | public abstract List getKotlinFiles(); 25 | 26 | private String project; 27 | 28 | public AbstractKotlinGenerator(String project) { 29 | this.project = project; 30 | } 31 | 32 | public String getProject() { 33 | return project; 34 | } 35 | 36 | public List listOf(KotlinFile...kotlinFiles) { 37 | return Arrays.asList(kotlinFiles); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /mybatis-generator-core/src/main/java/org/mybatis/generator/codegen/AbstractXmlGenerator.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2006-2017 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.mybatis.generator.codegen; 17 | 18 | import org.mybatis.generator.api.dom.xml.Document; 19 | 20 | public abstract class AbstractXmlGenerator extends AbstractGenerator { 21 | public abstract Document getDocument(); 22 | } 23 | -------------------------------------------------------------------------------- /mybatis-generator-core/src/main/java/org/mybatis/generator/codegen/XmlConstants.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2006-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.mybatis.generator.codegen; 17 | 18 | /** 19 | * Constants for MyBatis XML IDs. 20 | * 21 | * @author Jeff Butler 22 | */ 23 | public class XmlConstants { 24 | 25 | /** 26 | * Utility Class, no instances. 27 | */ 28 | private XmlConstants() { 29 | super(); 30 | } 31 | 32 | public static final String MYBATIS3_MAPPER_SYSTEM_ID = 33 | "http://mybatis.org/dtd/mybatis-3-mapper.dtd"; //$NON-NLS-1$ 34 | 35 | public static final String MYBATIS3_MAPPER_PUBLIC_ID = 36 | "-//mybatis.org//DTD Mapper 3.0//EN"; //$NON-NLS-1$ 37 | 38 | public static final String MYBATIS3_MAPPER_CONFIG_SYSTEM_ID = 39 | "http://mybatis.org/dtd/mybatis-3-config.dtd"; //$NON-NLS-1$ 40 | 41 | public static final String MYBATIS3_MAPPER_CONFIG_PUBLIC_ID = 42 | "-//mybatis.org//DTD Config 3.0//EN"; //$NON-NLS-1$ 43 | 44 | public static final String MYBATIS_GENERATOR_CONFIG_SYSTEM_ID = 45 | "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd"; //$NON-NLS-1$ 46 | 47 | public static final String MYBATIS_GENERATOR_CONFIG_PUBLIC_ID = 48 | "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"; //$NON-NLS-1$ 49 | } 50 | -------------------------------------------------------------------------------- /mybatis-generator-core/src/main/java/org/mybatis/generator/codegen/mybatis3/ListUtilities.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2006-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.mybatis.generator.codegen.mybatis3; 17 | 18 | import java.util.List; 19 | import java.util.stream.Collectors; 20 | 21 | import org.mybatis.generator.api.IntrospectedColumn; 22 | 23 | /** 24 | * Couple of little utility methods to make dealing with generated always 25 | * columns easier. If a column is GENERATED ALWAYS, it should not 26 | * be referenced on an insert or update method. 27 | * 28 | *

If a column is identity, it should not be referenced on an insert method. 29 | * 30 | * @author Jeff Butler 31 | * 32 | */ 33 | public class ListUtilities { 34 | 35 | private ListUtilities() {} 36 | 37 | public static List removeGeneratedAlwaysColumns(List columns) { 38 | return columns.stream() 39 | .filter(ic -> !ic.isGeneratedAlways()) 40 | .collect(Collectors.toList()); 41 | } 42 | 43 | public static List removeIdentityAndGeneratedAlwaysColumns(List columns) { 44 | return columns.stream() 45 | .filter(ic -> !ic.isGeneratedAlways() && !ic.isIdentity()) 46 | .collect(Collectors.toList()); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /mybatis-generator-core/src/main/java/org/mybatis/generator/codegen/mybatis3/javamapper/elements/annotated/AnnotatedCountByExampleMethodGenerator.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2006-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.mybatis.generator.codegen.mybatis3.javamapper.elements.annotated; 17 | 18 | import org.mybatis.generator.api.dom.java.FullyQualifiedJavaType; 19 | import org.mybatis.generator.api.dom.java.Interface; 20 | import org.mybatis.generator.api.dom.java.Method; 21 | import org.mybatis.generator.codegen.mybatis3.javamapper.elements.CountByExampleMethodGenerator; 22 | 23 | public class AnnotatedCountByExampleMethodGenerator extends CountByExampleMethodGenerator { 24 | 25 | public AnnotatedCountByExampleMethodGenerator() { 26 | super(); 27 | } 28 | 29 | @Override 30 | public void addMapperAnnotations(Method method) { 31 | FullyQualifiedJavaType fqjt = new FullyQualifiedJavaType(introspectedTable.getMyBatis3SqlProviderType()); 32 | StringBuilder sb = new StringBuilder(); 33 | sb.append("@SelectProvider(type="); //$NON-NLS-1$ 34 | sb.append(fqjt.getShortName()); 35 | sb.append(".class, method=\""); //$NON-NLS-1$ 36 | sb.append(introspectedTable.getCountByExampleStatementId()); 37 | sb.append("\")"); //$NON-NLS-1$ 38 | 39 | method.addAnnotation(sb.toString()); 40 | } 41 | 42 | @Override 43 | public void addExtraImports(Interface interfaze) { 44 | interfaze.addImportedType( 45 | new FullyQualifiedJavaType("org.apache.ibatis.annotations.SelectProvider")); //$NON-NLS-1$ 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /mybatis-generator-core/src/main/java/org/mybatis/generator/codegen/mybatis3/javamapper/elements/annotated/AnnotatedDeleteByExampleMethodGenerator.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2006-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.mybatis.generator.codegen.mybatis3.javamapper.elements.annotated; 17 | 18 | import org.mybatis.generator.api.dom.java.FullyQualifiedJavaType; 19 | import org.mybatis.generator.api.dom.java.Interface; 20 | import org.mybatis.generator.api.dom.java.Method; 21 | import org.mybatis.generator.codegen.mybatis3.javamapper.elements.DeleteByExampleMethodGenerator; 22 | 23 | public class AnnotatedDeleteByExampleMethodGenerator extends 24 | DeleteByExampleMethodGenerator { 25 | 26 | public AnnotatedDeleteByExampleMethodGenerator() { 27 | super(); 28 | } 29 | 30 | @Override 31 | public void addMapperAnnotations(Method method) { 32 | FullyQualifiedJavaType fqjt = new FullyQualifiedJavaType(introspectedTable.getMyBatis3SqlProviderType()); 33 | StringBuilder sb = new StringBuilder(); 34 | sb.append("@DeleteProvider(type="); //$NON-NLS-1$ 35 | sb.append(fqjt.getShortName()); 36 | sb.append(".class, method=\""); //$NON-NLS-1$ 37 | sb.append(introspectedTable.getDeleteByExampleStatementId()); 38 | sb.append("\")"); //$NON-NLS-1$ 39 | 40 | method.addAnnotation(sb.toString()); 41 | } 42 | 43 | @Override 44 | public void addExtraImports(Interface interfaze) { 45 | interfaze.addImportedType( 46 | new FullyQualifiedJavaType("org.apache.ibatis.annotations.DeleteProvider")); //$NON-NLS-1$ 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /mybatis-generator-core/src/main/java/org/mybatis/generator/codegen/mybatis3/javamapper/elements/annotated/AnnotatedUpdateByExampleSelectiveMethodGenerator.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2006-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.mybatis.generator.codegen.mybatis3.javamapper.elements.annotated; 17 | 18 | import org.mybatis.generator.api.dom.java.FullyQualifiedJavaType; 19 | import org.mybatis.generator.api.dom.java.Interface; 20 | import org.mybatis.generator.api.dom.java.Method; 21 | import org.mybatis.generator.codegen.mybatis3.javamapper.elements.UpdateByExampleSelectiveMethodGenerator; 22 | 23 | public class AnnotatedUpdateByExampleSelectiveMethodGenerator extends UpdateByExampleSelectiveMethodGenerator { 24 | 25 | public AnnotatedUpdateByExampleSelectiveMethodGenerator() { 26 | super(); 27 | } 28 | 29 | @Override 30 | public void addMapperAnnotations(Method method) { 31 | FullyQualifiedJavaType fqjt = new FullyQualifiedJavaType(introspectedTable.getMyBatis3SqlProviderType()); 32 | StringBuilder sb = new StringBuilder(); 33 | sb.append("@UpdateProvider(type="); //$NON-NLS-1$ 34 | sb.append(fqjt.getShortName()); 35 | sb.append(".class, method=\""); //$NON-NLS-1$ 36 | sb.append(introspectedTable.getUpdateByExampleSelectiveStatementId()); 37 | sb.append("\")"); //$NON-NLS-1$ 38 | 39 | method.addAnnotation(sb.toString()); 40 | } 41 | 42 | @Override 43 | public void addExtraImports(Interface interfaze) { 44 | interfaze.addImportedType( 45 | new FullyQualifiedJavaType("org.apache.ibatis.annotations.UpdateProvider")); //$NON-NLS-1$ 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /mybatis-generator-core/src/main/java/org/mybatis/generator/codegen/mybatis3/javamapper/elements/annotated/AnnotatedUpdateByExampleWithBLOBsMethodGenerator.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2006-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.mybatis.generator.codegen.mybatis3.javamapper.elements.annotated; 17 | 18 | import org.mybatis.generator.api.dom.java.FullyQualifiedJavaType; 19 | import org.mybatis.generator.api.dom.java.Interface; 20 | import org.mybatis.generator.api.dom.java.Method; 21 | import org.mybatis.generator.codegen.mybatis3.javamapper.elements.UpdateByExampleWithBLOBsMethodGenerator; 22 | 23 | public class AnnotatedUpdateByExampleWithBLOBsMethodGenerator extends UpdateByExampleWithBLOBsMethodGenerator { 24 | 25 | public AnnotatedUpdateByExampleWithBLOBsMethodGenerator() { 26 | super(); 27 | } 28 | 29 | @Override 30 | public void addMapperAnnotations(Method method) { 31 | FullyQualifiedJavaType fqjt = new FullyQualifiedJavaType(introspectedTable.getMyBatis3SqlProviderType()); 32 | StringBuilder sb = new StringBuilder(); 33 | sb.append("@UpdateProvider(type="); //$NON-NLS-1$ 34 | sb.append(fqjt.getShortName()); 35 | sb.append(".class, method=\""); //$NON-NLS-1$ 36 | sb.append(introspectedTable.getUpdateByExampleWithBLOBsStatementId()); 37 | sb.append("\")"); //$NON-NLS-1$ 38 | 39 | method.addAnnotation(sb.toString()); 40 | } 41 | 42 | @Override 43 | public void addExtraImports(Interface interfaze) { 44 | interfaze.addImportedType( 45 | new FullyQualifiedJavaType("org.apache.ibatis.annotations.UpdateProvider")); //$NON-NLS-1$ 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /mybatis-generator-core/src/main/java/org/mybatis/generator/codegen/mybatis3/javamapper/elements/annotated/AnnotatedUpdateByExampleWithoutBLOBsMethodGenerator.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2006-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.mybatis.generator.codegen.mybatis3.javamapper.elements.annotated; 17 | 18 | import org.mybatis.generator.api.dom.java.FullyQualifiedJavaType; 19 | import org.mybatis.generator.api.dom.java.Interface; 20 | import org.mybatis.generator.api.dom.java.Method; 21 | import org.mybatis.generator.codegen.mybatis3.javamapper.elements.UpdateByExampleWithoutBLOBsMethodGenerator; 22 | 23 | public class AnnotatedUpdateByExampleWithoutBLOBsMethodGenerator extends UpdateByExampleWithoutBLOBsMethodGenerator { 24 | 25 | public AnnotatedUpdateByExampleWithoutBLOBsMethodGenerator() { 26 | super(); 27 | } 28 | 29 | @Override 30 | public void addMapperAnnotations(Method method) { 31 | FullyQualifiedJavaType fqjt = new FullyQualifiedJavaType(introspectedTable.getMyBatis3SqlProviderType()); 32 | StringBuilder sb = new StringBuilder(); 33 | sb.append("@UpdateProvider(type="); //$NON-NLS-1$ 34 | sb.append(fqjt.getShortName()); 35 | sb.append(".class, method=\""); //$NON-NLS-1$ 36 | sb.append(introspectedTable.getUpdateByExampleStatementId()); 37 | sb.append("\")"); //$NON-NLS-1$ 38 | 39 | method.addAnnotation(sb.toString()); 40 | } 41 | 42 | @Override 43 | public void addExtraImports(Interface interfaze) { 44 | interfaze.addImportedType( 45 | new FullyQualifiedJavaType("org.apache.ibatis.annotations.UpdateProvider")); //$NON-NLS-1$ 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /mybatis-generator-core/src/main/java/org/mybatis/generator/codegen/mybatis3/javamapper/elements/annotated/AnnotatedUpdateByPrimaryKeySelectiveMethodGenerator.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2006-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.mybatis.generator.codegen.mybatis3.javamapper.elements.annotated; 17 | 18 | import org.mybatis.generator.api.dom.java.FullyQualifiedJavaType; 19 | import org.mybatis.generator.api.dom.java.Interface; 20 | import org.mybatis.generator.api.dom.java.Method; 21 | import org.mybatis.generator.codegen.mybatis3.javamapper.elements.UpdateByPrimaryKeySelectiveMethodGenerator; 22 | 23 | public class AnnotatedUpdateByPrimaryKeySelectiveMethodGenerator extends UpdateByPrimaryKeySelectiveMethodGenerator { 24 | 25 | public AnnotatedUpdateByPrimaryKeySelectiveMethodGenerator() { 26 | super(); 27 | } 28 | 29 | @Override 30 | public void addMapperAnnotations(Method method) { 31 | FullyQualifiedJavaType fqjt = new FullyQualifiedJavaType(introspectedTable.getMyBatis3SqlProviderType()); 32 | StringBuilder sb = new StringBuilder(); 33 | sb.append("@UpdateProvider(type="); //$NON-NLS-1$ 34 | sb.append(fqjt.getShortName()); 35 | sb.append(".class, method=\""); //$NON-NLS-1$ 36 | sb.append(introspectedTable.getUpdateByPrimaryKeySelectiveStatementId()); 37 | sb.append("\")"); //$NON-NLS-1$ 38 | 39 | method.addAnnotation(sb.toString()); 40 | } 41 | 42 | @Override 43 | public void addExtraImports(Interface interfaze) { 44 | interfaze.addImportedType( 45 | new FullyQualifiedJavaType("org.apache.ibatis.annotations.UpdateProvider")); //$NON-NLS-1$ 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /mybatis-generator-core/src/main/java/org/mybatis/generator/codegen/mybatis3/javamapper/elements/sqlprovider/AbstractJavaProviderMethodGenerator.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2006-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.mybatis.generator.codegen.mybatis3.javamapper.elements.sqlprovider; 17 | 18 | import org.mybatis.generator.api.dom.java.FullyQualifiedJavaType; 19 | import org.mybatis.generator.api.dom.java.TopLevelClass; 20 | import org.mybatis.generator.codegen.AbstractGenerator; 21 | 22 | public abstract class AbstractJavaProviderMethodGenerator extends 23 | AbstractGenerator { 24 | 25 | protected static final FullyQualifiedJavaType NEW_BUILDER_IMPORT = 26 | new FullyQualifiedJavaType("org.apache.ibatis.jdbc.SQL"); //$NON-NLS-1$ 27 | protected boolean useLegacyBuilder; 28 | protected final String builderPrefix; 29 | 30 | public AbstractJavaProviderMethodGenerator(boolean useLegacyBuilder) { 31 | super(); 32 | this.useLegacyBuilder = useLegacyBuilder; 33 | if (useLegacyBuilder) { 34 | builderPrefix = ""; //$NON-NLS-1$ 35 | } else { 36 | builderPrefix = "sql."; //$NON-NLS-1$ 37 | } 38 | } 39 | 40 | public abstract void addClassElements(TopLevelClass topLevelClass); 41 | } 42 | -------------------------------------------------------------------------------- /mybatis-generator-core/src/main/java/org/mybatis/generator/codegen/mybatis3/javamapper/elements/sqlprovider/ProviderSelectByExampleWithBLOBsMethodGenerator.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2006-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.mybatis.generator.codegen.mybatis3.javamapper.elements.sqlprovider; 17 | 18 | import java.util.List; 19 | 20 | import org.mybatis.generator.api.IntrospectedColumn; 21 | import org.mybatis.generator.api.dom.java.Method; 22 | import org.mybatis.generator.api.dom.java.TopLevelClass; 23 | 24 | public class ProviderSelectByExampleWithBLOBsMethodGenerator extends 25 | ProviderSelectByExampleWithoutBLOBsMethodGenerator { 26 | 27 | public ProviderSelectByExampleWithBLOBsMethodGenerator(boolean useLegacyBuilder) { 28 | super(useLegacyBuilder); 29 | } 30 | 31 | @Override 32 | public List getColumns() { 33 | return introspectedTable.getAllColumns(); 34 | } 35 | 36 | @Override 37 | public String getMethodName() { 38 | return introspectedTable.getSelectByExampleWithBLOBsStatementId(); 39 | } 40 | 41 | @Override 42 | public boolean callPlugins(Method method, TopLevelClass topLevelClass) { 43 | return context.getPlugins().providerSelectByExampleWithBLOBsMethodGenerated(method, topLevelClass, 44 | introspectedTable); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /mybatis-generator-core/src/main/java/org/mybatis/generator/codegen/mybatis3/javamapper/elements/sqlprovider/ProviderUpdateByExampleWithBLOBsMethodGenerator.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2006-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.mybatis.generator.codegen.mybatis3.javamapper.elements.sqlprovider; 17 | 18 | import java.util.List; 19 | 20 | import org.mybatis.generator.api.IntrospectedColumn; 21 | import org.mybatis.generator.api.dom.java.Method; 22 | import org.mybatis.generator.api.dom.java.TopLevelClass; 23 | 24 | public class ProviderUpdateByExampleWithBLOBsMethodGenerator extends 25 | ProviderUpdateByExampleWithoutBLOBsMethodGenerator { 26 | 27 | public ProviderUpdateByExampleWithBLOBsMethodGenerator(boolean useLegacyBuilder) { 28 | super(useLegacyBuilder); 29 | } 30 | 31 | @Override 32 | public String getMethodName() { 33 | return introspectedTable.getUpdateByExampleWithBLOBsStatementId(); 34 | } 35 | 36 | @Override 37 | public List getColumns() { 38 | return introspectedTable.getAllColumns(); 39 | } 40 | 41 | @Override 42 | public boolean callPlugins(Method method, TopLevelClass topLevelClass) { 43 | return context.getPlugins().providerUpdateByExampleWithBLOBsMethodGenerated(method, topLevelClass, 44 | introspectedTable); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /mybatis-generator-core/src/main/java/org/mybatis/generator/codegen/mybatis3/xmlmapper/MixedMapperGenerator.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2006-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.mybatis.generator.codegen.mybatis3.xmlmapper; 17 | 18 | import org.mybatis.generator.api.dom.xml.XmlElement; 19 | 20 | public class MixedMapperGenerator extends XMLMapperGenerator { 21 | 22 | @Override 23 | protected void addSelectByPrimaryKeyElement(XmlElement parentElement) { 24 | // turn off this element in the mixed mapper 25 | } 26 | 27 | @Override 28 | protected void addDeleteByPrimaryKeyElement(XmlElement parentElement) { 29 | // turn off this element in the mixed mapper 30 | } 31 | 32 | @Override 33 | protected void addInsertElement(XmlElement parentElement) { 34 | // turn off this element in the mixed mapper 35 | } 36 | 37 | @Override 38 | protected void addUpdateByPrimaryKeyWithBLOBsElement( 39 | XmlElement parentElement) { 40 | // turn off this element in the mixed mapper 41 | } 42 | 43 | @Override 44 | protected void addUpdateByPrimaryKeyWithoutBLOBsElement( 45 | XmlElement parentElement) { 46 | // turn off this element in the mixed mapper 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /mybatis-generator-core/src/main/java/org/mybatis/generator/codegen/mybatis3/xmlmapper/elements/DeleteByExampleElementGenerator.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2006-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.mybatis.generator.codegen.mybatis3.xmlmapper.elements; 17 | 18 | import org.mybatis.generator.api.dom.xml.Attribute; 19 | import org.mybatis.generator.api.dom.xml.TextElement; 20 | import org.mybatis.generator.api.dom.xml.XmlElement; 21 | 22 | public class DeleteByExampleElementGenerator extends 23 | AbstractXmlElementGenerator { 24 | 25 | public DeleteByExampleElementGenerator() { 26 | super(); 27 | } 28 | 29 | @Override 30 | public void addElements(XmlElement parentElement) { 31 | XmlElement answer = new XmlElement("delete"); //$NON-NLS-1$ 32 | 33 | String fqjt = introspectedTable.getExampleType(); 34 | 35 | answer.addAttribute(new Attribute( 36 | "id", introspectedTable.getDeleteByExampleStatementId())); //$NON-NLS-1$ 37 | answer.addAttribute(new Attribute("parameterType", fqjt)); //$NON-NLS-1$ 38 | 39 | context.getCommentGenerator().addComment(answer); 40 | 41 | StringBuilder sb = new StringBuilder(); 42 | sb.append("delete from "); //$NON-NLS-1$ 43 | sb.append(introspectedTable 44 | .getAliasedFullyQualifiedTableNameAtRuntime()); 45 | answer.addElement(new TextElement(sb.toString())); 46 | answer.addElement(getExampleIncludeElement()); 47 | 48 | if (context.getPlugins().sqlMapDeleteByExampleElementGenerated( 49 | answer, introspectedTable)) { 50 | parentElement.addElement(answer); 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /mybatis-generator-core/src/main/java/org/mybatis/generator/config/CommentGeneratorConfiguration.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2006-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.mybatis.generator.config; 17 | 18 | public class CommentGeneratorConfiguration extends TypedPropertyHolder { 19 | 20 | public CommentGeneratorConfiguration() { 21 | super(); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /mybatis-generator-core/src/main/java/org/mybatis/generator/config/ConnectionFactoryConfiguration.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2006-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.mybatis.generator.config; 17 | 18 | import static org.mybatis.generator.internal.util.messages.Messages.getString; 19 | 20 | import java.util.List; 21 | 22 | import org.mybatis.generator.internal.util.StringUtility; 23 | 24 | public class ConnectionFactoryConfiguration extends TypedPropertyHolder { 25 | 26 | public ConnectionFactoryConfiguration() { 27 | super(); 28 | } 29 | 30 | public void validate(List errors) { 31 | if (getConfigurationType() == null || "DEFAULT".equals(getConfigurationType())) { //$NON-NLS-1$ 32 | if (!StringUtility.stringHasValue(getProperty("driverClass"))) { //$NON-NLS-1$ 33 | errors.add(getString("ValidationError.18", //$NON-NLS-1$ 34 | "connectionFactory", //$NON-NLS-1$ 35 | "driverClass")); //$NON-NLS-1$ 36 | } 37 | 38 | if (!StringUtility.stringHasValue(getProperty("connectionURL"))) { //$NON-NLS-1$ 39 | errors.add(getString("ValidationError.18", //$NON-NLS-1$ 40 | "connectionFactory", //$NON-NLS-1$ 41 | "connectionURL")); //$NON-NLS-1$ 42 | } 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /mybatis-generator-core/src/main/java/org/mybatis/generator/config/IgnoredColumnException.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2006-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.mybatis.generator.config; 17 | 18 | import static org.mybatis.generator.internal.util.StringUtility.stringHasValue; 19 | import static org.mybatis.generator.internal.util.messages.Messages.getString; 20 | 21 | import java.util.List; 22 | 23 | public class IgnoredColumnException extends IgnoredColumn { 24 | 25 | public IgnoredColumnException(String columnName) { 26 | super(columnName); 27 | } 28 | 29 | @Override 30 | public void validate(List errors, String tableName) { 31 | if (!stringHasValue(columnName)) { 32 | errors.add(getString("ValidationError.26", //$NON-NLS-1$ 33 | tableName)); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /mybatis-generator-core/src/main/java/org/mybatis/generator/config/IgnoredColumnPattern.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2006-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.mybatis.generator.config; 17 | 18 | import static org.mybatis.generator.internal.util.StringUtility.stringHasValue; 19 | import static org.mybatis.generator.internal.util.messages.Messages.getString; 20 | 21 | import java.util.ArrayList; 22 | import java.util.List; 23 | import java.util.regex.Pattern; 24 | 25 | public class IgnoredColumnPattern { 26 | 27 | private String patternRegex; 28 | private Pattern pattern; 29 | private List exceptions = new ArrayList<>(); 30 | 31 | public IgnoredColumnPattern(String patternRegex) { 32 | this.patternRegex = patternRegex; 33 | pattern = Pattern.compile(patternRegex); 34 | } 35 | 36 | public void addException(IgnoredColumnException exception) { 37 | exceptions.add(exception); 38 | } 39 | 40 | public boolean matches(String columnName) { 41 | boolean matches = pattern.matcher(columnName).matches(); 42 | 43 | if (matches) { 44 | for (IgnoredColumnException exception : exceptions) { 45 | if (exception.matches(columnName)) { 46 | matches = false; 47 | break; 48 | } 49 | } 50 | } 51 | 52 | return matches; 53 | } 54 | 55 | public void validate(List errors, String tableName) { 56 | if (!stringHasValue(patternRegex)) { 57 | errors.add(getString("ValidationError.27", //$NON-NLS-1$ 58 | tableName)); 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /mybatis-generator-core/src/main/java/org/mybatis/generator/config/JavaClientGeneratorConfiguration.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2006-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.mybatis.generator.config; 17 | 18 | import static org.mybatis.generator.internal.util.StringUtility.stringHasValue; 19 | import static org.mybatis.generator.internal.util.messages.Messages.getString; 20 | 21 | import java.util.List; 22 | 23 | public class JavaClientGeneratorConfiguration extends TypedPropertyHolder { 24 | private String targetPackage; 25 | private String targetProject; 26 | 27 | public JavaClientGeneratorConfiguration() { 28 | super(); 29 | } 30 | 31 | public String getTargetProject() { 32 | return targetProject; 33 | } 34 | 35 | public void setTargetProject(String targetProject) { 36 | this.targetProject = targetProject; 37 | } 38 | 39 | public String getTargetPackage() { 40 | return targetPackage; 41 | } 42 | 43 | public void setTargetPackage(String targetPackage) { 44 | this.targetPackage = targetPackage; 45 | } 46 | 47 | public void validate(List errors, String contextId) { 48 | if (!stringHasValue(targetProject)) { 49 | errors.add(getString("ValidationError.2", contextId)); //$NON-NLS-1$ 50 | } 51 | 52 | if (!stringHasValue(targetPackage)) { 53 | errors.add(getString("ValidationError.12", //$NON-NLS-1$ 54 | "javaClientGenerator", contextId)); //$NON-NLS-1$ 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /mybatis-generator-core/src/main/java/org/mybatis/generator/config/JavaModelGeneratorConfiguration.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2006-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.mybatis.generator.config; 17 | 18 | import static org.mybatis.generator.internal.util.StringUtility.stringHasValue; 19 | import static org.mybatis.generator.internal.util.messages.Messages.getString; 20 | 21 | import java.util.List; 22 | 23 | public class JavaModelGeneratorConfiguration extends PropertyHolder { 24 | 25 | private String targetPackage; 26 | 27 | private String targetProject; 28 | 29 | public JavaModelGeneratorConfiguration() { 30 | super(); 31 | } 32 | 33 | public String getTargetProject() { 34 | return targetProject; 35 | } 36 | 37 | public void setTargetProject(String targetProject) { 38 | this.targetProject = targetProject; 39 | } 40 | 41 | public String getTargetPackage() { 42 | return targetPackage; 43 | } 44 | 45 | public void setTargetPackage(String targetPackage) { 46 | this.targetPackage = targetPackage; 47 | } 48 | 49 | public void validate(List errors, String contextId) { 50 | if (!stringHasValue(targetProject)) { 51 | errors.add(getString("ValidationError.0", contextId)); //$NON-NLS-1$ 52 | } 53 | 54 | if (!stringHasValue(targetPackage)) { 55 | errors.add(getString("ValidationError.12", //$NON-NLS-1$ 56 | "JavaModelGenerator", contextId)); //$NON-NLS-1$ 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /mybatis-generator-core/src/main/java/org/mybatis/generator/config/JavaTypeResolverConfiguration.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2006-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.mybatis.generator.config; 17 | 18 | public class JavaTypeResolverConfiguration extends TypedPropertyHolder { 19 | 20 | public JavaTypeResolverConfiguration() { 21 | super(); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /mybatis-generator-core/src/main/java/org/mybatis/generator/config/MergeConstants.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2006-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.mybatis.generator.config; 17 | 18 | import java.util.Arrays; 19 | 20 | /** 21 | * This class holds constants useful in the XML and Java merging operations. 22 | * 23 | * @author Jeff Butler 24 | * 25 | */ 26 | public class MergeConstants { 27 | 28 | /** 29 | * Utility class - no instances. 30 | * 31 | */ 32 | private MergeConstants() { 33 | } 34 | 35 | private static final String[] OLD_XML_ELEMENT_PREFIXES = { 36 | "ibatorgenerated_", "abatorgenerated_" }; //$NON-NLS-1$ //$NON-NLS-2$ 37 | 38 | public static final String NEW_ELEMENT_TAG = "@mbg.generated"; //$NON-NLS-1$ 39 | private static final String[] OLD_ELEMENT_TAGS = { 40 | "@ibatorgenerated", //$NON-NLS-1$ 41 | "@abatorgenerated", //$NON-NLS-1$ 42 | "@mbggenerated", //$NON-NLS-1$ 43 | NEW_ELEMENT_TAG }; 44 | 45 | public static String[] getOldElementTags() { 46 | return OLD_ELEMENT_TAGS; 47 | } 48 | 49 | public static boolean idStartsWithPrefix(String id) { 50 | return Arrays.stream(OLD_XML_ELEMENT_PREFIXES) 51 | .anyMatch(id::startsWith); 52 | } 53 | 54 | public static boolean commentContainsTag(String comment) { 55 | return Arrays.stream(OLD_ELEMENT_TAGS) 56 | .anyMatch(comment::contains); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /mybatis-generator-core/src/main/java/org/mybatis/generator/config/ModelType.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2006-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.mybatis.generator.config; 17 | 18 | import static org.mybatis.generator.internal.util.messages.Messages.getString; 19 | 20 | /** 21 | * Typesafe enum of different model types. 22 | * 23 | * @author Jeff Butler 24 | */ 25 | public enum ModelType { 26 | HIERARCHICAL("hierarchical"), //$NON-NLS-1$ 27 | FLAT("flat"), //$NON-NLS-1$ 28 | CONDITIONAL("conditional"); //$NON-NLS-1$ 29 | 30 | private final String type; 31 | 32 | ModelType(String type) { 33 | this.type = type; 34 | } 35 | 36 | public static ModelType getModelType(String type) { 37 | if (HIERARCHICAL.type.equalsIgnoreCase(type)) { 38 | return HIERARCHICAL; 39 | } else if (FLAT.type.equalsIgnoreCase(type)) { 40 | return FLAT; 41 | } else if (CONDITIONAL.type.equalsIgnoreCase(type)) { 42 | return CONDITIONAL; 43 | } else { 44 | throw new RuntimeException(getString( 45 | "RuntimeError.13", type)); //$NON-NLS-1$ 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /mybatis-generator-core/src/main/java/org/mybatis/generator/config/PluginConfiguration.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2006-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.mybatis.generator.config; 17 | 18 | import static org.mybatis.generator.internal.util.StringUtility.stringHasValue; 19 | import static org.mybatis.generator.internal.util.messages.Messages.getString; 20 | 21 | import java.util.List; 22 | 23 | public class PluginConfiguration extends TypedPropertyHolder { 24 | public PluginConfiguration() { 25 | super(); 26 | } 27 | 28 | public void validate(List errors, String contextId) { 29 | if (!stringHasValue(getConfigurationType())) { 30 | errors.add(getString("ValidationError.17", //$NON-NLS-1$ 31 | contextId)); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /mybatis-generator-core/src/main/java/org/mybatis/generator/config/PropertyHolder.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2006-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.mybatis.generator.config; 17 | 18 | import java.util.Enumeration; 19 | import java.util.Properties; 20 | 21 | import org.mybatis.generator.api.dom.xml.Attribute; 22 | import org.mybatis.generator.api.dom.xml.XmlElement; 23 | 24 | public abstract class PropertyHolder { 25 | private Properties properties; 26 | 27 | public PropertyHolder() { 28 | super(); 29 | properties = new Properties(); 30 | } 31 | 32 | public void addProperty(String name, String value) { 33 | properties.setProperty(name, value); 34 | } 35 | 36 | public String getProperty(String name) { 37 | return properties.getProperty(name); 38 | } 39 | 40 | public Properties getProperties() { 41 | return properties; 42 | } 43 | 44 | protected void addPropertyXmlElements(XmlElement xmlElement) { 45 | Enumeration enumeration = properties.propertyNames(); 46 | while (enumeration.hasMoreElements()) { 47 | String propertyName = (String) enumeration.nextElement(); 48 | 49 | XmlElement propertyElement = new XmlElement("property"); //$NON-NLS-1$ 50 | propertyElement.addAttribute(new Attribute("name", propertyName)); //$NON-NLS-1$ 51 | propertyElement.addAttribute(new Attribute( 52 | "value", properties.getProperty(propertyName))); //$NON-NLS-1$ 53 | xmlElement.addElement(propertyElement); 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /mybatis-generator-core/src/main/java/org/mybatis/generator/config/SqlMapGeneratorConfiguration.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2006-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.mybatis.generator.config; 17 | 18 | import static org.mybatis.generator.internal.util.StringUtility.stringHasValue; 19 | import static org.mybatis.generator.internal.util.messages.Messages.getString; 20 | 21 | import java.util.List; 22 | 23 | public class SqlMapGeneratorConfiguration extends PropertyHolder { 24 | private String targetPackage; 25 | 26 | private String targetProject; 27 | 28 | public SqlMapGeneratorConfiguration() { 29 | super(); 30 | } 31 | 32 | public String getTargetProject() { 33 | return targetProject; 34 | } 35 | 36 | public void setTargetProject(String targetProject) { 37 | this.targetProject = targetProject; 38 | } 39 | 40 | public String getTargetPackage() { 41 | return targetPackage; 42 | } 43 | 44 | public void setTargetPackage(String targetPackage) { 45 | this.targetPackage = targetPackage; 46 | } 47 | 48 | public void validate(List errors, String contextId) { 49 | if (!stringHasValue(targetProject)) { 50 | errors.add(getString("ValidationError.1", contextId)); //$NON-NLS-1$ 51 | } 52 | 53 | if (!stringHasValue(targetPackage)) { 54 | errors.add(getString("ValidationError.12", //$NON-NLS-1$ 55 | "SQLMapGenerator", contextId)); //$NON-NLS-1$ 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /mybatis-generator-core/src/main/java/org/mybatis/generator/config/TypedPropertyHolder.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2006-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.mybatis.generator.config; 17 | 18 | public abstract class TypedPropertyHolder extends PropertyHolder { 19 | 20 | private String configurationType; 21 | 22 | public TypedPropertyHolder() { 23 | super(); 24 | } 25 | 26 | public String getConfigurationType() { 27 | return configurationType; 28 | } 29 | 30 | /** 31 | * Sets the value of the type specified in the configuration. If the special 32 | * value DEFAULT is specified, then the value will be ignored. 33 | * 34 | * @param configurationType 35 | * the type specified in the configuration 36 | */ 37 | public void setConfigurationType(String configurationType) { 38 | if (!"DEFAULT".equalsIgnoreCase(configurationType)) { //$NON-NLS-1$ 39 | this.configurationType = configurationType; 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /mybatis-generator-core/src/main/java/org/mybatis/generator/config/xml/ParserEntityResolver.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2006-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.mybatis.generator.config.xml; 17 | 18 | import java.io.IOException; 19 | import java.io.InputStream; 20 | 21 | import org.mybatis.generator.codegen.XmlConstants; 22 | import org.xml.sax.EntityResolver; 23 | import org.xml.sax.InputSource; 24 | import org.xml.sax.SAXException; 25 | 26 | public class ParserEntityResolver implements EntityResolver { 27 | 28 | public ParserEntityResolver() { 29 | super(); 30 | } 31 | 32 | @Override 33 | public InputSource resolveEntity(String publicId, String systemId) 34 | throws SAXException, IOException { 35 | if (XmlConstants.MYBATIS_GENERATOR_CONFIG_PUBLIC_ID 36 | .equalsIgnoreCase(publicId)) { 37 | InputStream is = getClass() 38 | .getClassLoader() 39 | .getResourceAsStream( 40 | "org/mybatis/generator/config/xml/mybatis-generator-config_1_0.dtd"); //$NON-NLS-1$ 41 | return new InputSource(is); 42 | } else { 43 | return null; 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /mybatis-generator-core/src/main/java/org/mybatis/generator/config/xml/ParserErrorHandler.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2006-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.mybatis.generator.config.xml; 17 | 18 | import static org.mybatis.generator.internal.util.messages.Messages.getString; 19 | 20 | import java.util.List; 21 | 22 | import org.xml.sax.ErrorHandler; 23 | import org.xml.sax.SAXException; 24 | import org.xml.sax.SAXParseException; 25 | 26 | public class ParserErrorHandler implements ErrorHandler { 27 | 28 | private List warnings; 29 | 30 | private List errors; 31 | 32 | public ParserErrorHandler(List warnings, List errors) { 33 | super(); 34 | this.warnings = warnings; 35 | this.errors = errors; 36 | } 37 | 38 | @Override 39 | public void warning(SAXParseException exception) throws SAXException { 40 | warnings.add(getString("Warning.7", //$NON-NLS-1$ 41 | Integer.toString(exception.getLineNumber()), exception 42 | .getMessage())); 43 | } 44 | 45 | @Override 46 | public void error(SAXParseException exception) throws SAXException { 47 | errors.add(getString("RuntimeError.4", //$NON-NLS-1$ 48 | Integer.toString(exception.getLineNumber()), exception 49 | .getMessage())); 50 | } 51 | 52 | @Override 53 | public void fatalError(SAXParseException exception) throws SAXException { 54 | errors.add(getString("RuntimeError.4", //$NON-NLS-1$ 55 | Integer.toString(exception.getLineNumber()), exception 56 | .getMessage())); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /mybatis-generator-core/src/main/java/org/mybatis/generator/exception/InvalidConfigurationException.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2006-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.mybatis.generator.exception; 17 | 18 | import java.util.List; 19 | 20 | public class InvalidConfigurationException extends MultiMessageException { 21 | 22 | private static final long serialVersionUID = 4854214073644581094L; 23 | 24 | public InvalidConfigurationException(List errors) { 25 | super(errors); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /mybatis-generator-core/src/main/java/org/mybatis/generator/exception/MultiMessageException.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2006-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.mybatis.generator.exception; 17 | 18 | import java.util.ArrayList; 19 | import java.util.List; 20 | 21 | public class MultiMessageException extends Exception { 22 | 23 | private static final long serialVersionUID = -5358501949588130025L; 24 | private final List errors = new ArrayList<>(); 25 | 26 | public MultiMessageException(List errors) { 27 | this.errors.addAll(errors); 28 | } 29 | 30 | public MultiMessageException(String error) { 31 | this.errors.add(error); 32 | } 33 | 34 | public List getErrors() { 35 | return errors; 36 | } 37 | 38 | @Override 39 | public String getMessage() { 40 | return errors.get(0); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /mybatis-generator-core/src/main/java/org/mybatis/generator/exception/ShellException.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2006-2017 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.mybatis.generator.exception; 17 | 18 | /** 19 | * This class is used by the ShellCallback methods to denote unrecoverable 20 | * errors. 21 | * 22 | * @author Jeff Butler 23 | */ 24 | public class ShellException extends Exception { 25 | 26 | /** The Constant serialVersionUID. */ 27 | static final long serialVersionUID = -2026841561754434544L; 28 | 29 | /** 30 | * Instantiates a new shell exception. 31 | */ 32 | public ShellException() { 33 | super(); 34 | } 35 | 36 | /** 37 | * Instantiates a new shell exception. 38 | * 39 | * @param arg0 40 | * the arg0 41 | */ 42 | public ShellException(String arg0) { 43 | super(arg0); 44 | } 45 | 46 | /** 47 | * Instantiates a new shell exception. 48 | * 49 | * @param arg0 50 | * the arg0 51 | * @param arg1 52 | * the arg1 53 | */ 54 | public ShellException(String arg0, Throwable arg1) { 55 | super(arg0, arg1); 56 | } 57 | 58 | /** 59 | * Instantiates a new shell exception. 60 | * 61 | * @param arg0 62 | * the arg0 63 | */ 64 | public ShellException(Throwable arg0) { 65 | super(arg0); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /mybatis-generator-core/src/main/java/org/mybatis/generator/exception/XMLParserException.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2006-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.mybatis.generator.exception; 17 | 18 | import java.util.List; 19 | 20 | public class XMLParserException extends MultiMessageException { 21 | 22 | private static final long serialVersionUID = 3481108770555387812L; 23 | 24 | public XMLParserException(List errors) { 25 | super(errors); 26 | } 27 | 28 | public XMLParserException(String error) { 29 | super(error); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /mybatis-generator-core/src/main/java/org/mybatis/generator/internal/NullProgressCallback.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2006-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.mybatis.generator.internal; 17 | 18 | import org.mybatis.generator.api.ProgressCallback; 19 | 20 | /** 21 | * This class implements a progress callback that does nothing. It is used when 22 | * the client passes in a null for the ProgressCallback. 23 | * 24 | * @author Jeff Butler 25 | */ 26 | public class NullProgressCallback implements ProgressCallback { 27 | 28 | public NullProgressCallback() { 29 | super(); 30 | } 31 | 32 | @Override 33 | public void generationStarted(int totalTasks) { 34 | // nothing to do in the null callback 35 | } 36 | 37 | @Override 38 | public void introspectionStarted(int totalTasks) { 39 | // nothing to do in the null callback 40 | } 41 | 42 | @Override 43 | public void saveStarted(int totalTasks) { 44 | // nothing to do in the null callback 45 | } 46 | 47 | @Override 48 | public void startTask(String taskName) { 49 | // nothing to do in the null callback 50 | } 51 | 52 | @Override 53 | public void checkCancel() throws InterruptedException { 54 | // nothing to do in the null callback 55 | } 56 | 57 | @Override 58 | public void done() { 59 | // nothing to do in the null callback 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /mybatis-generator-core/src/main/java/org/mybatis/generator/internal/PluginAggregator.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2006-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.mybatis.generator.internal; 17 | 18 | import java.util.List; 19 | import java.util.Properties; 20 | 21 | import org.mybatis.generator.api.CompositePlugin; 22 | import org.mybatis.generator.config.Context; 23 | 24 | /** 25 | * This class is for internal use only. It contains a list of plugins for the 26 | * current context and is used to aggregate plugins together. This class 27 | * implements the rule that if any plugin returns "false" from a method, then no 28 | * subsequent plugin is called. 29 | * 30 | *

This class does not follow the normal plugin lifecycle and should not be 31 | * subclassed by clients. 32 | * 33 | * @author Jeff Butler 34 | * 35 | */ 36 | public final class PluginAggregator extends CompositePlugin { 37 | 38 | @Override 39 | public void setContext(Context context) { 40 | throw new UnsupportedOperationException(); 41 | } 42 | 43 | @Override 44 | public void setProperties(Properties properties) { 45 | throw new UnsupportedOperationException(); 46 | } 47 | 48 | @Override 49 | public boolean validate(List warnings) { 50 | throw new UnsupportedOperationException(); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /mybatis-generator-core/src/main/java/org/mybatis/generator/internal/db/ActualTableName.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2006-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.mybatis.generator.internal.db; 17 | 18 | import static org.mybatis.generator.internal.util.StringUtility.composeFullyQualifiedTableName; 19 | 20 | /** 21 | * This class holds the actual catalog, schema, and table name returned from the 22 | * database introspection. 23 | * 24 | * @author Jeff Butler 25 | * 26 | */ 27 | public class ActualTableName { 28 | 29 | private String tableName; 30 | private String catalog; 31 | private String schema; 32 | private String fullName; 33 | 34 | public ActualTableName(String catalog, String schema, String tableName) { 35 | this.catalog = catalog; 36 | this.schema = schema; 37 | this.tableName = tableName; 38 | fullName = composeFullyQualifiedTableName(catalog, 39 | schema, tableName, '.'); 40 | } 41 | 42 | public String getCatalog() { 43 | return catalog; 44 | } 45 | 46 | public String getSchema() { 47 | return schema; 48 | } 49 | 50 | public String getTableName() { 51 | return tableName; 52 | } 53 | 54 | @Override 55 | public boolean equals(Object obj) { 56 | if (!(obj instanceof ActualTableName)) { 57 | return false; 58 | } 59 | 60 | return obj.toString().equals(this.toString()); 61 | } 62 | 63 | @Override 64 | public int hashCode() { 65 | return fullName.hashCode(); 66 | } 67 | 68 | @Override 69 | public String toString() { 70 | return fullName; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /mybatis-generator-core/src/main/java/org/mybatis/generator/internal/rules/FlatModelRules.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2006-2017 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.mybatis.generator.internal.rules; 17 | 18 | import org.mybatis.generator.api.IntrospectedTable; 19 | 20 | /** 21 | * This class encapsulates all the code generation rules for a table using the 22 | * flat model. 23 | * 24 | * @author Jeff Butler 25 | * 26 | */ 27 | public class FlatModelRules extends BaseRules { 28 | 29 | /** 30 | * Instantiates a new flat model rules. 31 | * 32 | * @param introspectedTable 33 | * the introspected table 34 | */ 35 | public FlatModelRules(IntrospectedTable introspectedTable) { 36 | super(introspectedTable); 37 | } 38 | 39 | /** 40 | * We never generate a primary key in the flat model. 41 | * 42 | * @return true if the primary key should be generated 43 | */ 44 | @Override 45 | public boolean generatePrimaryKeyClass() { 46 | return false; 47 | } 48 | 49 | /** 50 | * We always generate a base record in the flat model. 51 | * 52 | * @return true if the class should be generated 53 | */ 54 | @Override 55 | public boolean generateBaseRecordClass() { 56 | return true; 57 | } 58 | 59 | /** 60 | * We never generate a record with BLOBs class in the flat model. 61 | * 62 | * @return true if the record with BLOBs class should be generated 63 | */ 64 | @Override 65 | public boolean generateRecordWithBLOBsClass() { 66 | return false; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /mybatis-generator-core/src/main/java/org/mybatis/generator/internal/util/CustomCollectors.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2006-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.mybatis.generator.internal.util; 17 | 18 | import java.util.StringJoiner; 19 | import java.util.stream.Collector; 20 | 21 | public interface CustomCollectors { 22 | 23 | /** 24 | * Returns a {@code Collector} similar to the standard JDK joining collector, except that 25 | * this collector returns an empty string if there are no elements to collect. 26 | * 27 | * @param delimiter the delimiter to be used between each element 28 | * @param prefix the sequence of characters to be used at the beginning 29 | * of the joined result 30 | * @param suffix the sequence of characters to be used at the end 31 | * of the joined result 32 | * @return A {@code Collector} which concatenates CharSequence elements, 33 | * separated by the specified delimiter, in encounter order 34 | */ 35 | static Collector joining(CharSequence delimiter, CharSequence prefix, 36 | CharSequence suffix) { 37 | return Collector.of(() -> { 38 | StringJoiner sj = new StringJoiner(delimiter, prefix, suffix); 39 | sj.setEmptyValue(""); //$NON-NLS-1$ 40 | return sj; 41 | }, StringJoiner::add, StringJoiner::merge, StringJoiner::toString); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /mybatis-generator-core/src/main/java/org/mybatis/generator/logging/AbstractLogFactory.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2006-2017 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.mybatis.generator.logging; 17 | 18 | /** 19 | * Defines the interface for creating Log implementations. 20 | * 21 | * @author Jeff Butler 22 | * 23 | */ 24 | public interface AbstractLogFactory { 25 | Log getLog(Class targetClass); 26 | } 27 | -------------------------------------------------------------------------------- /mybatis-generator-core/src/main/java/org/mybatis/generator/logging/Log.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2006-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.mybatis.generator.logging; 17 | 18 | public interface Log { 19 | 20 | boolean isDebugEnabled(); 21 | 22 | void error(String s, Throwable e); 23 | 24 | void error(String s); 25 | 26 | void debug(String s); 27 | 28 | void warn(String s); 29 | } 30 | -------------------------------------------------------------------------------- /mybatis-generator-core/src/main/java/org/mybatis/generator/logging/LogException.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2006-2017 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.mybatis.generator.logging; 17 | 18 | public class LogException extends RuntimeException { 19 | 20 | private static final long serialVersionUID = 7522435242386492002L; 21 | 22 | public LogException() { 23 | super(); 24 | } 25 | 26 | public LogException(String message) { 27 | super(message); 28 | } 29 | 30 | public LogException(String message, Throwable cause) { 31 | super(message, cause); 32 | } 33 | 34 | public LogException(Throwable cause) { 35 | super(cause); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /mybatis-generator-core/src/main/java/org/mybatis/generator/logging/commons/JakartaCommonsLoggingImpl.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2006-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.mybatis.generator.logging.commons; 17 | 18 | import org.apache.commons.logging.Log; 19 | import org.apache.commons.logging.LogFactory; 20 | 21 | public class JakartaCommonsLoggingImpl implements org.mybatis.generator.logging.Log { 22 | 23 | private Log log; 24 | 25 | public JakartaCommonsLoggingImpl(Class clazz) { 26 | log = LogFactory.getLog(clazz); 27 | } 28 | 29 | @Override 30 | public boolean isDebugEnabled() { 31 | return log.isDebugEnabled(); 32 | } 33 | 34 | @Override 35 | public void error(String s, Throwable e) { 36 | log.error(s, e); 37 | } 38 | 39 | @Override 40 | public void error(String s) { 41 | log.error(s); 42 | } 43 | 44 | @Override 45 | public void debug(String s) { 46 | log.debug(s); 47 | } 48 | 49 | @Override 50 | public void warn(String s) { 51 | log.warn(s); 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /mybatis-generator-core/src/main/java/org/mybatis/generator/logging/commons/JakartaCommonsLoggingLogFactory.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2006-2017 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.mybatis.generator.logging.commons; 17 | 18 | import org.mybatis.generator.logging.AbstractLogFactory; 19 | import org.mybatis.generator.logging.Log; 20 | 21 | public class JakartaCommonsLoggingLogFactory implements AbstractLogFactory { 22 | @Override 23 | public Log getLog(Class clazz) { 24 | return new JakartaCommonsLoggingImpl(clazz); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /mybatis-generator-core/src/main/java/org/mybatis/generator/logging/jdk14/Jdk14LoggingImpl.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2006-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.mybatis.generator.logging.jdk14; 17 | 18 | import java.util.logging.Level; 19 | import java.util.logging.Logger; 20 | 21 | import org.mybatis.generator.logging.Log; 22 | 23 | public class Jdk14LoggingImpl implements Log { 24 | 25 | private Logger log; 26 | 27 | public Jdk14LoggingImpl(Class clazz) { 28 | log = Logger.getLogger(clazz.getName()); 29 | } 30 | 31 | @Override 32 | public boolean isDebugEnabled() { 33 | return log.isLoggable(Level.FINE); 34 | } 35 | 36 | @Override 37 | public void error(String s, Throwable e) { 38 | log.log(Level.SEVERE, s, e); 39 | } 40 | 41 | @Override 42 | public void error(String s) { 43 | log.log(Level.SEVERE, s); 44 | } 45 | 46 | @Override 47 | public void debug(String s) { 48 | log.log(Level.FINE, s); 49 | } 50 | 51 | @Override 52 | public void warn(String s) { 53 | log.log(Level.WARNING, s); 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /mybatis-generator-core/src/main/java/org/mybatis/generator/logging/jdk14/Jdk14LoggingLogFactory.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2006-2017 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.mybatis.generator.logging.jdk14; 17 | 18 | import org.mybatis.generator.logging.AbstractLogFactory; 19 | import org.mybatis.generator.logging.Log; 20 | 21 | public class Jdk14LoggingLogFactory implements AbstractLogFactory { 22 | @Override 23 | public Log getLog(Class clazz) { 24 | return new Jdk14LoggingImpl(clazz); 25 | } 26 | } -------------------------------------------------------------------------------- /mybatis-generator-core/src/main/java/org/mybatis/generator/logging/log4j/Log4jImpl.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2006-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.mybatis.generator.logging.log4j; 17 | 18 | import org.apache.log4j.Level; 19 | import org.apache.log4j.Logger; 20 | import org.mybatis.generator.logging.Log; 21 | 22 | public class Log4jImpl implements Log { 23 | 24 | private static final String FQCN = Log4jImpl.class.getName(); 25 | 26 | private Logger log; 27 | 28 | public Log4jImpl(Class clazz) { 29 | log = Logger.getLogger(clazz); 30 | } 31 | 32 | @Override 33 | public boolean isDebugEnabled() { 34 | return log.isDebugEnabled(); 35 | } 36 | 37 | @Override 38 | public void error(String s, Throwable e) { 39 | log.log(FQCN, Level.ERROR, s, e); 40 | } 41 | 42 | @Override 43 | public void error(String s) { 44 | log.log(FQCN, Level.ERROR, s, null); 45 | } 46 | 47 | @Override 48 | public void debug(String s) { 49 | log.log(FQCN, Level.DEBUG, s, null); 50 | } 51 | 52 | @Override 53 | public void warn(String s) { 54 | log.log(FQCN, Level.WARN, s, null); 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /mybatis-generator-core/src/main/java/org/mybatis/generator/logging/log4j/Log4jLoggingLogFactory.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2006-2017 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.mybatis.generator.logging.log4j; 17 | 18 | import org.mybatis.generator.logging.AbstractLogFactory; 19 | import org.mybatis.generator.logging.Log; 20 | 21 | public class Log4jLoggingLogFactory implements AbstractLogFactory { 22 | @Override 23 | public Log getLog(Class clazz) { 24 | return new Log4jImpl(clazz); 25 | } 26 | } -------------------------------------------------------------------------------- /mybatis-generator-core/src/main/java/org/mybatis/generator/logging/log4j2/Log4j2Impl.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2006-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.mybatis.generator.logging.log4j2; 17 | 18 | import org.apache.logging.log4j.LogManager; 19 | import org.apache.logging.log4j.Logger; 20 | import org.apache.logging.log4j.spi.AbstractLogger; 21 | import org.mybatis.generator.logging.Log; 22 | 23 | public class Log4j2Impl implements Log { 24 | 25 | private Log log; 26 | 27 | public Log4j2Impl(Class clazz) { 28 | Logger logger = LogManager.getLogger(clazz); 29 | 30 | if (logger instanceof AbstractLogger) { 31 | log = new Log4j2AbstractLoggerImpl((AbstractLogger) logger); 32 | } else { 33 | log = new Log4j2LoggerImpl(logger); 34 | } 35 | } 36 | 37 | @Override 38 | public boolean isDebugEnabled() { 39 | return log.isDebugEnabled(); 40 | } 41 | 42 | @Override 43 | public void error(String s, Throwable e) { 44 | log.error(s, e); 45 | } 46 | 47 | @Override 48 | public void error(String s) { 49 | log.error(s); 50 | } 51 | 52 | @Override 53 | public void debug(String s) { 54 | log.debug(s); 55 | } 56 | 57 | @Override 58 | public void warn(String s) { 59 | log.warn(s); 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /mybatis-generator-core/src/main/java/org/mybatis/generator/logging/log4j2/Log4j2LoggerImpl.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2006-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.mybatis.generator.logging.log4j2; 17 | 18 | import org.apache.logging.log4j.Logger; 19 | import org.apache.logging.log4j.Marker; 20 | import org.apache.logging.log4j.MarkerManager; 21 | import org.mybatis.generator.logging.Log; 22 | import org.mybatis.generator.logging.LogFactory; 23 | 24 | public class Log4j2LoggerImpl implements Log { 25 | 26 | private static final Marker MARKER = MarkerManager.getMarker(LogFactory.MARKER); 27 | 28 | private Logger log; 29 | 30 | public Log4j2LoggerImpl(Logger logger) { 31 | log = logger; 32 | } 33 | 34 | @Override 35 | public boolean isDebugEnabled() { 36 | return log.isDebugEnabled(); 37 | } 38 | 39 | @Override 40 | public void error(String s, Throwable e) { 41 | log.error(MARKER, s, e); 42 | } 43 | 44 | @Override 45 | public void error(String s) { 46 | log.error(MARKER, s); 47 | } 48 | 49 | @Override 50 | public void debug(String s) { 51 | log.debug(MARKER, s); 52 | } 53 | 54 | @Override 55 | public void warn(String s) { 56 | log.warn(MARKER, s); 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /mybatis-generator-core/src/main/java/org/mybatis/generator/logging/log4j2/Log4j2LoggingLogFactory.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2006-2017 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.mybatis.generator.logging.log4j2; 17 | 18 | import org.mybatis.generator.logging.AbstractLogFactory; 19 | import org.mybatis.generator.logging.Log; 20 | 21 | public class Log4j2LoggingLogFactory implements AbstractLogFactory { 22 | @Override 23 | public Log getLog(Class clazz) { 24 | return new Log4j2Impl(clazz); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /mybatis-generator-core/src/main/java/org/mybatis/generator/logging/nologging/NoLoggingImpl.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2006-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.mybatis.generator.logging.nologging; 17 | 18 | import org.mybatis.generator.logging.Log; 19 | 20 | public class NoLoggingImpl implements Log { 21 | 22 | public NoLoggingImpl() { 23 | // Do Nothing 24 | } 25 | 26 | @Override 27 | public boolean isDebugEnabled() { 28 | return false; 29 | } 30 | 31 | @Override 32 | public void error(String s, Throwable e) { 33 | // Do Nothing 34 | } 35 | 36 | @Override 37 | public void error(String s) { 38 | // Do Nothing 39 | } 40 | 41 | @Override 42 | public void debug(String s) { 43 | // Do Nothing 44 | } 45 | 46 | @Override 47 | public void warn(String s) { 48 | // Do Nothing 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /mybatis-generator-core/src/main/java/org/mybatis/generator/logging/nologging/NoLoggingLogFactory.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2006-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.mybatis.generator.logging.nologging; 17 | 18 | import org.mybatis.generator.logging.AbstractLogFactory; 19 | import org.mybatis.generator.logging.Log; 20 | 21 | public class NoLoggingLogFactory implements AbstractLogFactory { 22 | @Override 23 | public Log getLog(Class clazz) { 24 | return new NoLoggingImpl(); 25 | } 26 | } -------------------------------------------------------------------------------- /mybatis-generator-core/src/main/java/org/mybatis/generator/logging/slf4j/Slf4jLocationAwareLoggerImpl.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2006-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.mybatis.generator.logging.slf4j; 17 | 18 | import org.mybatis.generator.logging.Log; 19 | import org.mybatis.generator.logging.LogFactory; 20 | import org.slf4j.Marker; 21 | import org.slf4j.MarkerFactory; 22 | import org.slf4j.spi.LocationAwareLogger; 23 | 24 | class Slf4jLocationAwareLoggerImpl implements Log { 25 | 26 | private static final Marker MARKER = MarkerFactory.getMarker(LogFactory.MARKER); 27 | 28 | private static final String FQCN = Slf4jImpl.class.getName(); 29 | 30 | private LocationAwareLogger logger; 31 | 32 | Slf4jLocationAwareLoggerImpl(LocationAwareLogger logger) { 33 | this.logger = logger; 34 | } 35 | 36 | @Override 37 | public boolean isDebugEnabled() { 38 | return logger.isDebugEnabled(); 39 | } 40 | 41 | @Override 42 | public void error(String s, Throwable e) { 43 | logger.log(MARKER, FQCN, LocationAwareLogger.ERROR_INT, s, null, e); 44 | } 45 | 46 | @Override 47 | public void error(String s) { 48 | logger.log(MARKER, FQCN, LocationAwareLogger.ERROR_INT, s, null, null); 49 | } 50 | 51 | @Override 52 | public void debug(String s) { 53 | logger.log(MARKER, FQCN, LocationAwareLogger.DEBUG_INT, s, null, null); 54 | } 55 | 56 | @Override 57 | public void warn(String s) { 58 | logger.log(MARKER, FQCN, LocationAwareLogger.WARN_INT, s, null, null); 59 | } 60 | 61 | } 62 | -------------------------------------------------------------------------------- /mybatis-generator-core/src/main/java/org/mybatis/generator/logging/slf4j/Slf4jLoggerImpl.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2006-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.mybatis.generator.logging.slf4j; 17 | 18 | import org.mybatis.generator.logging.Log; 19 | import org.slf4j.Logger; 20 | 21 | class Slf4jLoggerImpl implements Log { 22 | 23 | private Logger log; 24 | 25 | public Slf4jLoggerImpl(Logger logger) { 26 | log = logger; 27 | } 28 | 29 | @Override 30 | public boolean isDebugEnabled() { 31 | return log.isDebugEnabled(); 32 | } 33 | 34 | @Override 35 | public void error(String s, Throwable e) { 36 | log.error(s, e); 37 | } 38 | 39 | @Override 40 | public void error(String s) { 41 | log.error(s); 42 | } 43 | 44 | @Override 45 | public void debug(String s) { 46 | log.debug(s); 47 | } 48 | 49 | @Override 50 | public void warn(String s) { 51 | log.warn(s); 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /mybatis-generator-core/src/main/java/org/mybatis/generator/logging/slf4j/Slf4jLoggingLogFactory.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2006-2017 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.mybatis.generator.logging.slf4j; 17 | 18 | import org.mybatis.generator.logging.AbstractLogFactory; 19 | import org.mybatis.generator.logging.Log; 20 | 21 | public class Slf4jLoggingLogFactory implements AbstractLogFactory { 22 | @Override 23 | public Log getLog(Class clazz) { 24 | return new Slf4jImpl(clazz); 25 | } 26 | } -------------------------------------------------------------------------------- /mybatis-generator-core/src/main/java/org/mybatis/generator/plugins/MapperAnnotationPlugin.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2006-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.mybatis.generator.plugins; 17 | 18 | import java.util.List; 19 | 20 | import org.mybatis.generator.api.IntrospectedTable; 21 | import org.mybatis.generator.api.IntrospectedTable.TargetRuntime; 22 | import org.mybatis.generator.api.PluginAdapter; 23 | import org.mybatis.generator.api.dom.java.FullyQualifiedJavaType; 24 | import org.mybatis.generator.api.dom.java.Interface; 25 | 26 | public class MapperAnnotationPlugin extends PluginAdapter { 27 | 28 | @Override 29 | public boolean validate(List warnings) { 30 | return true; 31 | } 32 | 33 | @Override 34 | public boolean clientGenerated(Interface interfaze, IntrospectedTable introspectedTable) { 35 | 36 | if (introspectedTable.getTargetRuntime() == TargetRuntime.MYBATIS3) { 37 | // don't need to do this for MYBATIS3_DSQL as that runtime already adds this annotation 38 | interfaze.addImportedType( 39 | new FullyQualifiedJavaType("org.apache.ibatis.annotations.Mapper")); //$NON-NLS-1$ 40 | interfaze.addAnnotation("@Mapper"); //$NON-NLS-1$ 41 | } 42 | return true; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /mybatis-generator-core/src/main/java/org/mybatis/generator/plugins/UnmergeableXmlMappersPlugin.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2006-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.mybatis.generator.plugins; 17 | 18 | import java.util.List; 19 | 20 | import org.mybatis.generator.api.GeneratedXmlFile; 21 | import org.mybatis.generator.api.IntrospectedTable; 22 | import org.mybatis.generator.api.PluginAdapter; 23 | 24 | /** 25 | * This plugin marks generated XML mapper files as unmergeable. This will cause the generator to either 26 | * overwrite the files, or save the files under a new name depending on how the overwrite setting is configured. 27 | * 28 | *

This can be useful when comments are disabled so the normal XML merge won't work. 29 | * 30 | * @author Jeff Butler 31 | * 32 | */ 33 | public class UnmergeableXmlMappersPlugin extends PluginAdapter { 34 | 35 | @Override 36 | public boolean validate(List warnings) { 37 | return true; 38 | } 39 | 40 | @Override 41 | public boolean sqlMapGenerated(GeneratedXmlFile sqlMap, 42 | IntrospectedTable introspectedTable) { 43 | sqlMap.setMergeable(false); 44 | return true; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /mybatis-generator-core/src/main/java/org/mybatis/generator/plugins/dsql/ReadOnlyPlugin.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2006-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.mybatis.generator.plugins.dsql; 17 | 18 | import java.util.List; 19 | 20 | import org.mybatis.generator.api.CompositePlugin; 21 | 22 | /** 23 | * Disables delete, insert, delete, and update methods in the MyBatisDynamicSQLV2 runtime. 24 | * 25 | * @author Jeff Butler 26 | * 27 | */ 28 | public class ReadOnlyPlugin extends CompositePlugin { 29 | 30 | public ReadOnlyPlugin() { 31 | addPlugin(new DisableDeletePlugin()); 32 | addPlugin(new DisableInsertPlugin()); 33 | addPlugin(new DisableUpdatePlugin()); 34 | } 35 | 36 | @Override 37 | public boolean validate(List warnings) { 38 | return true; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /mybatis-generator-core/src/main/java/org/mybatis/generator/runtime/dynamic/sql/IntrospectedTableMyBatis3DynamicSqlImplV2.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2006-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.mybatis.generator.runtime.dynamic.sql; 17 | 18 | import org.mybatis.generator.codegen.AbstractJavaClientGenerator; 19 | 20 | public class IntrospectedTableMyBatis3DynamicSqlImplV2 extends IntrospectedTableMyBatis3DynamicSqlImplV1 { 21 | 22 | @Override 23 | protected AbstractJavaClientGenerator createJavaClientGenerator() { 24 | if (context.getJavaClientGeneratorConfiguration() == null) { 25 | return null; 26 | } 27 | 28 | return new DynamicSqlMapperGeneratorV2(getClientProject()); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /mybatis-generator-core/src/main/java/org/mybatis/generator/runtime/kotlin/elements/KotlinFunctionAndImports.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2006-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.mybatis.generator.runtime.kotlin.elements; 17 | 18 | import java.util.HashSet; 19 | import java.util.Set; 20 | 21 | import org.mybatis.generator.api.dom.kotlin.KotlinFunction; 22 | 23 | public class KotlinFunctionAndImports { 24 | 25 | private KotlinFunction function; 26 | private Set imports; 27 | 28 | private KotlinFunctionAndImports(Builder builder) { 29 | function = builder.function; 30 | imports = builder.imports; 31 | } 32 | 33 | public KotlinFunction getFunction() { 34 | return function; 35 | } 36 | 37 | public Set getImports() { 38 | return imports; 39 | } 40 | 41 | public static Builder withFunction(KotlinFunction function) { 42 | return new Builder().withFunction(function); 43 | } 44 | 45 | public static class Builder { 46 | private KotlinFunction function; 47 | private Set imports = new HashSet<>(); 48 | 49 | public Builder withFunction(KotlinFunction function) { 50 | this.function = function; 51 | return this; 52 | } 53 | 54 | public Builder withImport(String im) { 55 | this.imports.add(im); 56 | return this; 57 | } 58 | 59 | public Builder withImports(Set imports) { 60 | this.imports.addAll(imports); 61 | return this; 62 | } 63 | 64 | public KotlinFunctionAndImports build() { 65 | return new KotlinFunctionAndImports(this); 66 | } 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /mybatis-generator-gui/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | /config/ 3 | .idea 4 | .settings 5 | logs 6 | *.iml 7 | .project 8 | .classpath 9 | #/src/main/resources/sqlite3.db 10 | -------------------------------------------------------------------------------- /mybatis-generator-gui/_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-cayman -------------------------------------------------------------------------------- /mybatis-generator-gui/package/macosx/mybatis-generator-gui.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/derotyoung/mybatis-generator-gui-plus/4e5424b1e72074504863b1791c4ee7a6bf6ccadb/mybatis-generator-gui/package/macosx/mybatis-generator-gui.icns -------------------------------------------------------------------------------- /mybatis-generator-gui/package/windows/mybatis-generator-gui.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/derotyoung/mybatis-generator-gui-plus/4e5424b1e72074504863b1791c4ee7a6bf6ccadb/mybatis-generator-gui/package/windows/mybatis-generator-gui.ico -------------------------------------------------------------------------------- /mybatis-generator-gui/src/main/java/com/zzg/mybatis/generator/App.java: -------------------------------------------------------------------------------- 1 | package com.zzg.mybatis.generator; 2 | 3 | import com.zzg.mybatis.generator.controller.MainUIController; 4 | import com.zzg.mybatis.generator.util.ConfigHelper; 5 | import javafx.application.Application; 6 | import javafx.fxml.FXMLLoader; 7 | import javafx.scene.Parent; 8 | import javafx.scene.Scene; 9 | import javafx.stage.Stage; 10 | 11 | import java.net.URL; 12 | 13 | public class App extends Application { 14 | 15 | @Override 16 | public void start(Stage primaryStage) throws Exception { 17 | ConfigHelper.createEmptyFiles(); 18 | URL url = Thread.currentThread().getContextClassLoader().getResource("fxml/MainUI.fxml"); 19 | FXMLLoader fxmlLoader = new FXMLLoader(url); 20 | Parent root = fxmlLoader.load(); 21 | primaryStage.setResizable(true); 22 | primaryStage.setScene(new Scene(root)); 23 | primaryStage.show(); 24 | 25 | MainUIController controller = fxmlLoader.getController(); 26 | controller.setPrimaryStage(primaryStage); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /mybatis-generator-gui/src/main/java/com/zzg/mybatis/generator/MainUI.java: -------------------------------------------------------------------------------- 1 | package com.zzg.mybatis.generator; 2 | 3 | import javafx.application.Application; 4 | 5 | /** 6 | * 这是本软件的主入口,要运行本软件请直接运行本类就可以了,不用传入任何参数 7 | * 本软件要求 jdk 版本大于1.8.0.40 8 | */ 9 | public class MainUI { 10 | 11 | public static void main(String[] args) { 12 | Application.launch(App.class, args); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /mybatis-generator-gui/src/main/java/com/zzg/mybatis/generator/controller/FXMLPage.java: -------------------------------------------------------------------------------- 1 | package com.zzg.mybatis.generator.controller; 2 | 3 | /** 4 | * FXML User Interface enum 5 | *

6 | * Created by Owen on 6/20/16. 7 | */ 8 | public enum FXMLPage { 9 | 10 | NEW_CONNECTION("fxml/newConnection.fxml"), 11 | SELECT_TABLE_COLUMN("fxml/selectTableColumn.fxml"), 12 | GENERATOR_CONFIG("fxml/generatorConfigs.fxml"), 13 | ; 14 | 15 | private String fxml; 16 | 17 | FXMLPage(String fxml) { 18 | this.fxml = fxml; 19 | } 20 | 21 | public String getFxml() { 22 | return this.fxml; 23 | } 24 | 25 | 26 | } 27 | -------------------------------------------------------------------------------- /mybatis-generator-gui/src/main/java/com/zzg/mybatis/generator/exception/DbDriverLoadingException.java: -------------------------------------------------------------------------------- 1 | package com.zzg.mybatis.generator.exception; 2 | 3 | /** 4 | * 数据库驱动加载异常 5 | * @Date 2017/8/15 21:46 6 | * @Author jy 7 | */ 8 | public class DbDriverLoadingException extends RuntimeException{ 9 | 10 | public DbDriverLoadingException(String message){ 11 | super(message); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /mybatis-generator-gui/src/main/java/com/zzg/mybatis/generator/model/CachedFXMLLoader.java: -------------------------------------------------------------------------------- 1 | package com.zzg.mybatis.generator.model; 2 | 3 | public class CachedFXMLLoader { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /mybatis-generator-gui/src/main/java/com/zzg/mybatis/generator/model/DatabaseDTO.java: -------------------------------------------------------------------------------- 1 | package com.zzg.mybatis.generator.model; 2 | 3 | public class DatabaseDTO { 4 | 5 | private String name; 6 | private int value; 7 | private String driverClass; 8 | 9 | public String getName() { 10 | return name; 11 | } 12 | 13 | public void setName(String name) { 14 | this.name = name; 15 | } 16 | 17 | public int getValue() { 18 | return value; 19 | } 20 | 21 | public void setValue(int value) { 22 | this.value = value; 23 | } 24 | 25 | public String getDriverClass() { 26 | return driverClass; 27 | } 28 | 29 | public void setDriverClass(String driverClass) { 30 | this.driverClass = driverClass; 31 | } 32 | 33 | @Override 34 | public String toString() { 35 | return name; 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /mybatis-generator-gui/src/main/java/com/zzg/mybatis/generator/model/DbType.java: -------------------------------------------------------------------------------- 1 | package com.zzg.mybatis.generator.model; 2 | 3 | /** 4 | * Created by Owen on 6/14/16. 5 | */ 6 | public enum DbType { 7 | 8 | MySQL("com.mysql.jdbc.Driver", "jdbc:mysql://%s:%s/%s?useUnicode=true&useSSL=false&characterEncoding=%s", "mysql-connector-java-5.1.38.jar"), 9 | MySQL_8("com.mysql.cj.jdbc.Driver", "jdbc:mysql://%s:%s/%s?serverTimezone=UTC&useUnicode=true&useSSL=false&characterEncoding=%s", "mysql-connector-java-8.0.11.jar"), 10 | Oracle("oracle.jdbc.OracleDriver", "jdbc:oracle:thin:@//%s:%s/%s", "ojdbc6.jar"), 11 | PostgreSQL("org.postgresql.Driver", "jdbc:postgresql://%s:%s/%s", "postgresql-9.4.1209.jar"), 12 | SQL_Server("com.microsoft.sqlserver.jdbc.SQLServerDriver", "jdbc:sqlserver://%s:%s;databaseName=%s", "sqljdbc4-4.0.jar"), 13 | Sqlite("org.sqlite.JDBC", "jdbc:sqlite:%s", "sqlite-jdbc-3.19.3.jar"); 14 | 15 | private final String driverClass; 16 | private final String connectionUrlPattern; 17 | private final String connectorJarFile; 18 | 19 | DbType(String driverClass, String connectionUrlPattern, String connectorJarFile) { 20 | this.driverClass = driverClass; 21 | this.connectionUrlPattern = connectionUrlPattern; 22 | this.connectorJarFile = connectorJarFile; 23 | } 24 | 25 | public String getDriverClass() { 26 | return driverClass; 27 | } 28 | 29 | public String getConnectionUrlPattern() { 30 | return connectionUrlPattern; 31 | } 32 | 33 | public String getConnectorJarFile() { 34 | return connectorJarFile; 35 | } 36 | } -------------------------------------------------------------------------------- /mybatis-generator-gui/src/main/java/com/zzg/mybatis/generator/plugins/JavaTypeResolverJsr310Impl.java: -------------------------------------------------------------------------------- 1 | package com.zzg.mybatis.generator.plugins; 2 | 3 | import org.mybatis.generator.api.IntrospectedColumn; 4 | import org.mybatis.generator.api.dom.java.FullyQualifiedJavaType; 5 | import org.mybatis.generator.internal.types.JavaTypeResolverDefaultImpl; 6 | 7 | import java.sql.Types; 8 | import java.time.LocalDate; 9 | import java.time.LocalDateTime; 10 | import java.time.LocalTime; 11 | 12 | /** 13 | * @author hanakei 14 | * @since 2018/4/28 15 | */ 16 | public class JavaTypeResolverJsr310Impl extends JavaTypeResolverDefaultImpl { 17 | 18 | @Override 19 | protected FullyQualifiedJavaType overrideDefaultType(IntrospectedColumn column, FullyQualifiedJavaType defaultType) { 20 | FullyQualifiedJavaType answer = defaultType; 21 | 22 | switch (column.getJdbcType()) { 23 | case Types.BIT: 24 | answer = calculateBitReplacement(column, defaultType); 25 | break; 26 | case Types.DECIMAL: 27 | case Types.NUMERIC: 28 | answer = calculateBigDecimalReplacement(column, defaultType); 29 | break; 30 | case Types.DATE: 31 | answer = new FullyQualifiedJavaType(LocalDate.class.getName()); 32 | break; 33 | case Types.TIME: 34 | answer = new FullyQualifiedJavaType(LocalTime.class.getName()); 35 | break; 36 | case Types.TIMESTAMP: 37 | answer = new FullyQualifiedJavaType(LocalDateTime.class.getName()); 38 | break; 39 | default: 40 | break; 41 | } 42 | 43 | return answer; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /mybatis-generator-gui/src/main/java/com/zzg/mybatis/generator/plugins/RepositoryPlugin.java: -------------------------------------------------------------------------------- 1 | package com.zzg.mybatis.generator.plugins; 2 | 3 | import org.mybatis.generator.api.IntrospectedTable; 4 | import org.mybatis.generator.api.PluginAdapter; 5 | import org.mybatis.generator.api.dom.java.*; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * Project: mybatis-generator-gui 11 | * 12 | * @author slankka on 2017/12/13. 13 | */ 14 | public class RepositoryPlugin extends PluginAdapter { 15 | 16 | private FullyQualifiedJavaType annotationRepository; 17 | private String annotation = "@Repository"; 18 | 19 | public RepositoryPlugin () { 20 | annotationRepository = new FullyQualifiedJavaType("org.springframework.stereotype.Repository"); //$NON-NLS-1$ 21 | } 22 | 23 | @Override 24 | public boolean validate(List list) { 25 | return true; 26 | } 27 | 28 | @Override 29 | public boolean clientGenerated(Interface interfaze, IntrospectedTable introspectedTable) { 30 | interfaze.addImportedType(annotationRepository); 31 | interfaze.addAnnotation(annotation); 32 | return true; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /mybatis-generator-gui/src/main/java/com/zzg/mybatis/generator/util/ConnectionManager.java: -------------------------------------------------------------------------------- 1 | package com.zzg.mybatis.generator.util; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | 6 | import java.io.File; 7 | import java.sql.Connection; 8 | import java.sql.DriverManager; 9 | 10 | /** 11 | * Created by Owen on 8/21/16. 12 | */ 13 | public class ConnectionManager { 14 | 15 | private static final Logger _LOG = LoggerFactory.getLogger(ConnectionManager.class); 16 | 17 | private static final String DB_URL = "jdbc:sqlite:./config/sqlite3.db"; 18 | 19 | public static Connection getConnection() throws Exception { 20 | Class.forName("org.sqlite.JDBC"); 21 | File file = new File(DB_URL.substring("jdbc:sqlite:".length())).getAbsoluteFile(); 22 | _LOG.info("database FilePath :{}", file.getAbsolutePath()); 23 | Connection conn = DriverManager.getConnection(DB_URL); 24 | return conn; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /mybatis-generator-gui/src/main/java/com/zzg/mybatis/generator/util/MyStringUtils.java: -------------------------------------------------------------------------------- 1 | package com.zzg.mybatis.generator.util; 2 | 3 | /** 4 | * Created by Owen on 6/18/16. 5 | */ 6 | public class MyStringUtils { 7 | 8 | /** 9 | * convert string from slash style to camel style, such as my_course will convert to MyCourse 10 | */ 11 | public static String dbStringToCamelStyle(String str) { 12 | if (str != null) { 13 | if (str.contains("_")) { 14 | str = str.toLowerCase(); 15 | StringBuilder sb = new StringBuilder(); 16 | sb.append(String.valueOf(str.charAt(0)).toUpperCase()); 17 | for (int i = 1; i < str.length(); i++) { 18 | char c = str.charAt(i); 19 | if (c != '_') { 20 | sb.append(c); 21 | } else { 22 | if (i + 1 < str.length()) { 23 | sb.append(String.valueOf(str.charAt(i + 1)).toUpperCase()); 24 | i++; 25 | } 26 | } 27 | } 28 | return sb.toString(); 29 | } else { 30 | String firstChar = String.valueOf(str.charAt(0)).toUpperCase(); 31 | String otherChars = str.substring(1); 32 | return firstChar + otherChars; 33 | } 34 | } 35 | return null; 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /mybatis-generator-gui/src/main/java/com/zzg/mybatis/generator/view/AlertUtil.java: -------------------------------------------------------------------------------- 1 | package com.zzg.mybatis.generator.view; 2 | 3 | import javafx.scene.control.Alert; 4 | 5 | /** 6 | * Created by Owen on 6/21/16. 7 | */ 8 | public class AlertUtil { 9 | 10 | public static void showInfoAlert(String message) { 11 | Alert alert = new Alert(Alert.AlertType.INFORMATION); 12 | alert.setContentText(message); 13 | alert.show(); 14 | } 15 | 16 | public static void showWarnAlert(String message) { 17 | Alert alert = new Alert(Alert.AlertType.WARNING); 18 | alert.setContentText(message); 19 | alert.show(); 20 | } 21 | 22 | public static void showErrorAlert(String message) { 23 | Alert alert = new Alert(Alert.AlertType.ERROR); 24 | alert.setContentText(message); 25 | alert.show(); 26 | } 27 | 28 | /** 29 | * build both OK and Cancel buttons for the user 30 | * to click on to dismiss the dialog. 31 | * 32 | * @param message 33 | */ 34 | public static Alert buildConfirmationAlert(String message) { 35 | Alert alert = new Alert(Alert.AlertType.CONFIRMATION); 36 | alert.setContentText(message); 37 | return alert; 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /mybatis-generator-gui/src/main/java/com/zzg/mybatis/generator/view/UIProgressCallback.java: -------------------------------------------------------------------------------- 1 | package com.zzg.mybatis.generator.view; 2 | 3 | import javafx.beans.property.SimpleStringProperty; 4 | import javafx.beans.property.StringProperty; 5 | import javafx.scene.control.Alert; 6 | import org.mybatis.generator.api.ProgressCallback; 7 | 8 | /** 9 | * Created by Owen on 6/21/16. 10 | */ 11 | public class UIProgressCallback extends Alert implements ProgressCallback { 12 | 13 | private StringProperty progressText = new SimpleStringProperty(); 14 | 15 | public UIProgressCallback(AlertType alertType) { 16 | super(alertType); 17 | this.contentTextProperty().bindBidirectional(progressText); 18 | } 19 | 20 | @Override 21 | public void introspectionStarted(int totalTasks) { 22 | progressText.setValue("开始代码检查"); 23 | } 24 | 25 | @Override 26 | public void generationStarted(int totalTasks) { 27 | progressText.setValue("开始代码生成"); 28 | } 29 | 30 | @Override 31 | public void saveStarted(int totalTasks) { 32 | progressText.setValue("开始保存生成的文件"); 33 | } 34 | 35 | @Override 36 | public void startTask(String taskName) { 37 | progressText.setValue("代码生成任务开始"); 38 | } 39 | 40 | @Override 41 | public void done() { 42 | progressText.setValue("代码生成完成"); 43 | } 44 | 45 | @Override 46 | public void checkCancel() throws InterruptedException { 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /mybatis-generator-gui/src/main/resources/fxml/generatorConfigs.fxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /mybatis-generator-gui/src/main/resources/fxml/selectTableColumn.fxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 |