You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2022/04/09 07:50:15 UTC

[GitHub] [shardingsphere] ShiFengCui commented on a diff in pull request #16667: Add verification of config.yaml configuration to provide user-friendly prompts

ShiFengCui commented on code in PR #16667:
URL: https://github.com/apache/shardingsphere/pull/16667#discussion_r846596540


##########
examples/shardingsphere-example-generator/src/main/java/org/apache/shardingsphere/example/generator/core/ExampleGeneratorFactory.java:
##########
@@ -53,13 +54,14 @@ private Configuration createTemplateConfiguration() throws IOException {
     
     /**
      * Generate directories and files by template.
-     * 
+     *
      * @throws TemplateException template exception
      * @throws IOException IO exception
      */
     @SuppressWarnings("unchecked")
     public void generate() throws TemplateException, IOException {
         YamlExampleConfiguration exampleConfiguration = swapConfigToObject();
+        new YamlExampleConfigurationValidator().validate(exampleConfiguration);

Review Comment:
   ok



##########
examples/shardingsphere-example-generator/src/main/java/org/apache/shardingsphere/example/generator/core/yaml/config/YamlExampleConfigurationValidator.java:
##########
@@ -0,0 +1,89 @@
+/*
+ * 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.core.yaml.config;
+
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Sets;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+
+/**
+ * Example configuration validator.
+ */
+public class YamlExampleConfigurationValidator {
+    
+    /**
+     * Verify the entrance.
+     *
+     * @param configuration configuration
+     */
+    public void validate(final YamlExampleConfiguration configuration) {
+        Map<String, ConfigurationData> valueMap = new HashMap<>();
+        valueMap.put("products", new ConfigurationData(configuration.getProducts(), Sets.newHashSet("jdbc", "proxy")));

Review Comment:
   ok



-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org