totalo commented on a change in pull request #15386:
URL: https://github.com/apache/shardingsphere/pull/15386#discussion_r805252345



##########
File path: 
examples/shardingsphere-sample/shardingsphere-example-generator/src/main/java/org/apache/shardingsphere/example/generator/GenerateUtil.java
##########
@@ -0,0 +1,131 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
+ *
+ *     http://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.apache.shardingsphere.example.generator;
+
+import freemarker.template.Configuration;
+import freemarker.template.Template;
+import freemarker.template.TemplateException;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.StringWriter;
+import java.io.Writer;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Map;
+
+/**
+ * Freemarker generate util
+ */
+public final class GenerateUtil {
+    
+    /**
+     * Generate dirs.
+     * 
+     * @param templateConfig template config
+     * @param dataModel data model
+     * @param paths paths
+     * @param outputPath output path
+     * @throws IOException IO exception
+     * @throws TemplateException template exception
+     */
+    @SuppressWarnings("ResultOfMethodCallIgnored")
+    public static void generateDirs(final Configuration templateConfig, final 
Map<String, String> dataModel, final Collection<String> paths, final String 
outputPath) throws IOException, TemplateException {
+        if (null == paths || 0 == paths.size()) {
+            new File(generatePath(templateConfig, dataModel, 
outputPath)).mkdirs();
+            return;
+        }
+        for (String each : paths) {
+            new File(generatePath(templateConfig, dataModel, outputPath + "/" 
+ each)).mkdirs();
+        }
+    }
+    
+    /**
+     * Generate file.
+     * 
+     * @param templateConfig template config
+     * @param dataModel data model
+     * @param path paths
+     * @throws IOException IO exception
+     * @throws TemplateException template exception
+     */
+    public static void generateFile(final Configuration templateConfig, final 
Map<String, String> dataModel, final Map<String, String> templateMap, final 
String path) throws IOException, TemplateException {
+        String outputPath = generatePath(templateConfig, dataModel, path);
+        for (Map.Entry<String, String> entry : templateMap.entrySet()) {

Review comment:
       All right, thanks




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to