forked from mybatis/generator
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
45 changed files
with
3,140 additions
and
24 deletions.
There are no files selected for viewing
70 changes: 70 additions & 0 deletions
70
...ore/src/main/java/org/mybatis/generator/codegen/IntrospectedTableGenerateNothingImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/* | ||
* Copyright 2006-2023 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.mybatis.generator.codegen; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import org.mybatis.generator.api.GeneratedJavaFile; | ||
import org.mybatis.generator.api.GeneratedKotlinFile; | ||
import org.mybatis.generator.api.GeneratedXmlFile; | ||
import org.mybatis.generator.api.IntrospectedTable; | ||
import org.mybatis.generator.api.ProgressCallback; | ||
|
||
/** | ||
* Introspected table implementation for generating nothing. | ||
*/ | ||
public class IntrospectedTableGenerateNothingImpl extends IntrospectedTable { | ||
|
||
public IntrospectedTableGenerateNothingImpl() { | ||
this(TargetRuntime.MYBATIS3_DSQL); | ||
} | ||
|
||
public IntrospectedTableGenerateNothingImpl(TargetRuntime targetRuntime) { | ||
super(targetRuntime); | ||
} | ||
|
||
@Override | ||
public void calculateGenerators(List<String> warnings, ProgressCallback progressCallback) { | ||
//no generator | ||
} | ||
|
||
@Override | ||
public List<GeneratedJavaFile> getGeneratedJavaFiles() { | ||
return new ArrayList<>(0); | ||
} | ||
|
||
@Override | ||
public List<GeneratedXmlFile> getGeneratedXmlFiles() { | ||
return new ArrayList<>(0); | ||
} | ||
|
||
@Override | ||
public List<GeneratedKotlinFile> getGeneratedKotlinFiles() { | ||
return new ArrayList<>(0); | ||
} | ||
|
||
@Override | ||
public int getGenerationSteps() { | ||
return 0; | ||
} | ||
|
||
@Override | ||
public boolean requiresXMLGenerator() { | ||
return false; | ||
} | ||
|
||
} |
24 changes: 24 additions & 0 deletions
24
...main/java/org/mybatis/generator/codegen/IntrospectedTableGenerateNothingMyBatis3Impl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Copyright 2006-2023 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.mybatis.generator.codegen; | ||
|
||
public class IntrospectedTableGenerateNothingMyBatis3Impl extends IntrospectedTableGenerateNothingImpl { | ||
|
||
public IntrospectedTableGenerateNothingMyBatis3Impl() { | ||
super(TargetRuntime.MYBATIS3); | ||
} | ||
|
||
} |
52 changes: 52 additions & 0 deletions
52
...erator-core/src/main/java/org/mybatis/generator/plugins/AbstracKotlinGeneratorPlugin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* Copyright 2006-2023 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.mybatis.generator.plugins; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import org.mybatis.generator.api.GeneratedKotlinFile; | ||
import org.mybatis.generator.api.IntrospectedTable; | ||
import org.mybatis.generator.api.dom.kotlin.KotlinFile; | ||
import org.mybatis.generator.codegen.AbstractKotlinGenerator; | ||
import org.mybatis.generator.config.PropertyRegistry; | ||
|
||
public abstract class AbstracKotlinGeneratorPlugin extends AbstractGeneratorPlugin { | ||
|
||
@Override | ||
public abstract AbstractKotlinGenerator getGenerator(IntrospectedTable introspectedTable); | ||
|
||
@Override | ||
public List<GeneratedKotlinFile> contextGenerateAdditionalKotlinFiles(IntrospectedTable introspectedTable) { | ||
AbstractKotlinGenerator generator = getGenerator(introspectedTable); | ||
if (generator == null) { | ||
return new ArrayList<>(0); | ||
} | ||
initGenerator(generator, introspectedTable); | ||
|
||
List<GeneratedKotlinFile> answer = new ArrayList<>(); | ||
List<KotlinFile> kotlinFiles = generator.getKotlinFiles(); | ||
for (KotlinFile kotlinFile : kotlinFiles) { | ||
GeneratedKotlinFile gjf = new GeneratedKotlinFile(kotlinFile, | ||
getProject(), | ||
context.getProperty(PropertyRegistry.CONTEXT_KOTLIN_FILE_ENCODING), | ||
context.getKotlinFormatter()); | ||
answer.add(gjf); | ||
} | ||
return answer; | ||
} | ||
|
||
} |
53 changes: 53 additions & 0 deletions
53
...s-generator-core/src/main/java/org/mybatis/generator/plugins/AbstractGeneratorPlugin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* Copyright 2006-2023 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.mybatis.generator.plugins; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import org.mybatis.generator.api.IntrospectedTable; | ||
import org.mybatis.generator.api.PluginAdapter; | ||
import org.mybatis.generator.api.ProgressCallback; | ||
import org.mybatis.generator.codegen.AbstractGenerator; | ||
|
||
public abstract class AbstractGeneratorPlugin extends PluginAdapter { | ||
|
||
public static final String TARGET_PROJECT_PROPERTY = "targetProject"; | ||
|
||
public static final ProgressCallback NULL_PROGRESS_CALLBACK = new ProgressCallback() {}; | ||
|
||
@Override | ||
public boolean validate(List<String> warnings) { | ||
return true; | ||
} | ||
|
||
public abstract AbstractGenerator getGenerator(IntrospectedTable introspectedTable); | ||
|
||
protected String getProject() { | ||
return properties.getProperty(TARGET_PROJECT_PROPERTY); | ||
} | ||
|
||
protected void initGenerator(AbstractGenerator generator, | ||
IntrospectedTable introspectedTable) { | ||
generator.setContext(context); | ||
generator.setIntrospectedTable(introspectedTable); | ||
generator.setProgressCallback(NULL_PROGRESS_CALLBACK); | ||
generator.setWarnings(new ArrayList<>(0)); | ||
} | ||
|
||
|
||
|
||
} |
43 changes: 43 additions & 0 deletions
43
...r-core/src/main/java/org/mybatis/generator/plugins/AbstractJavaClientGeneratorPlugin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Copyright 2006-2023 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.mybatis.generator.plugins; | ||
|
||
import org.mybatis.generator.api.IntrospectedTable; | ||
import org.mybatis.generator.codegen.AbstractJavaClientGenerator; | ||
|
||
public abstract class AbstractJavaClientGeneratorPlugin | ||
extends AbstractJavaGeneratorPlugin { | ||
|
||
@Override | ||
public AbstractJavaClientGenerator getGenerator( | ||
IntrospectedTable introspectedTable) { | ||
if (!introspectedTable.getRules().generateJavaClient() | ||
|| context.getJavaClientGeneratorConfiguration() == null) { | ||
return null; | ||
} | ||
return getClientGenerator(introspectedTable); | ||
} | ||
|
||
public String getType() { | ||
if (context.getJavaClientGeneratorConfiguration() == null) { | ||
return null; | ||
} | ||
return context.getJavaClientGeneratorConfiguration().getConfigurationType(); | ||
} | ||
|
||
public abstract AbstractJavaClientGenerator getClientGenerator(IntrospectedTable introspectedTable); | ||
|
||
} |
52 changes: 52 additions & 0 deletions
52
...nerator-core/src/main/java/org/mybatis/generator/plugins/AbstractJavaGeneratorPlugin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* Copyright 2006-2023 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.mybatis.generator.plugins; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import org.mybatis.generator.api.GeneratedJavaFile; | ||
import org.mybatis.generator.api.IntrospectedTable; | ||
import org.mybatis.generator.api.dom.java.CompilationUnit; | ||
import org.mybatis.generator.codegen.AbstractJavaGenerator; | ||
import org.mybatis.generator.config.PropertyRegistry; | ||
|
||
public abstract class AbstractJavaGeneratorPlugin extends AbstractGeneratorPlugin { | ||
|
||
@Override | ||
public abstract AbstractJavaGenerator getGenerator(IntrospectedTable introspectedTable); | ||
|
||
@Override | ||
public List<GeneratedJavaFile> contextGenerateAdditionalJavaFiles(IntrospectedTable introspectedTable) { | ||
AbstractJavaGenerator generator = getGenerator(introspectedTable); | ||
if (generator == null) { | ||
return new ArrayList<>(0); | ||
} | ||
initGenerator(generator, introspectedTable); | ||
|
||
List<GeneratedJavaFile> answer = new ArrayList<>(); | ||
List<CompilationUnit> compilationUnits = generator.getCompilationUnits(); | ||
for (CompilationUnit compilationUnit : compilationUnits) { | ||
GeneratedJavaFile gjf = new GeneratedJavaFile(compilationUnit, | ||
getProject(), | ||
context.getProperty(PropertyRegistry.CONTEXT_JAVA_FILE_ENCODING), | ||
context.getJavaFormatter()); | ||
answer.add(gjf); | ||
} | ||
return answer; | ||
} | ||
|
||
} |
87 changes: 87 additions & 0 deletions
87
...enerator-core/src/main/java/org/mybatis/generator/plugins/AbstractXmlGeneratorPlugin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
/* | ||
* Copyright 2006-2023 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.mybatis.generator.plugins; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import org.mybatis.generator.api.GeneratedXmlFile; | ||
import org.mybatis.generator.api.IntrospectedTable; | ||
import org.mybatis.generator.api.dom.xml.Document; | ||
import org.mybatis.generator.codegen.AbstractJavaClientGenerator; | ||
import org.mybatis.generator.codegen.AbstractXmlGenerator; | ||
|
||
public abstract class AbstractXmlGeneratorPlugin extends AbstractGeneratorPlugin { | ||
|
||
private ClientCompositePlugin clientPlugin; | ||
|
||
public AbstractXmlGeneratorPlugin(ClientCompositePlugin clientPlugin) { | ||
super(); | ||
this.clientPlugin = clientPlugin; | ||
} | ||
|
||
public ClientCompositePlugin getClientPlugin() { | ||
return clientPlugin; | ||
} | ||
|
||
public void setClientPlugin(MyBatis3ClientCompositePlugin clientPlugin) { | ||
this.clientPlugin = clientPlugin; | ||
} | ||
|
||
public abstract AbstractXmlGenerator getXmlGenerator(IntrospectedTable introspectedTable); | ||
|
||
@Override | ||
public List<GeneratedXmlFile> contextGenerateAdditionalXmlFiles(IntrospectedTable introspectedTable) { | ||
AbstractXmlGenerator generator = getGenerator(introspectedTable); | ||
if (generator == null) { | ||
return new ArrayList<>(0); | ||
} | ||
initGenerator(generator, introspectedTable); | ||
|
||
List<GeneratedXmlFile> answer = new ArrayList<>(); | ||
Document document = generator.getDocument(); | ||
GeneratedXmlFile gxf = new GeneratedXmlFile(document, | ||
introspectedTable.getMyBatis3XmlMapperFileName(), | ||
introspectedTable.getMyBatis3XmlMapperPackage(), | ||
getProject(), true, context.getXmlFormatter()); | ||
if (context.getPlugins().sqlMapGenerated(gxf, introspectedTable)) { | ||
answer.add(gxf); | ||
} | ||
return answer; | ||
} | ||
|
||
@Override | ||
public AbstractXmlGenerator getGenerator( | ||
IntrospectedTable introspectedTable) { | ||
AbstractXmlGenerator xmlMapperGenerator; | ||
if (getClientPlugin() != null) { | ||
AbstractJavaClientGenerator javaClientGenerator = getClientPlugin().getClientGenerator(introspectedTable); | ||
if (javaClientGenerator == null) { | ||
if (context.getSqlMapGeneratorConfiguration() != null) { | ||
xmlMapperGenerator = getXmlGenerator(introspectedTable); | ||
} else { | ||
xmlMapperGenerator = null; | ||
} | ||
} else { | ||
xmlMapperGenerator = javaClientGenerator.getMatchedXMLGenerator(); | ||
} | ||
} else { | ||
xmlMapperGenerator = getXmlGenerator(introspectedTable); | ||
} | ||
return xmlMapperGenerator; | ||
} | ||
|
||
} |
Oops, something went wrong.