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 | *