You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by "Pace2Car (via GitHub)" <gi...@apache.org> on 2023/04/13 09:08:02 UTC

[GitHub] [shardingsphere] Pace2Car commented on a diff in pull request #25041: [#24755] Improve property verification of MaskAlgorithm

Pace2Car commented on code in PR #25041:
URL: https://github.com/apache/shardingsphere/pull/25041#discussion_r1165236004


##########
features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/MaskAlgorithmPropsChecker.java:
##########
@@ -81,4 +81,32 @@ public static void checkIntegerTypeConfig(final Properties props, final String i
             throw new MaskAlgorithmInitializationException(maskType, String.format("%s must be a valid integer number", integerTypeConfigKey));
         }
     }
+    
+    /**
+     * Check non-empty string type config.
+     *
+     * @param nonEmptyStringConfigValue non-empty string config value
+     * @param nonEmptyStringConfigKey non-empty string config key
+     * @param maskType mask type
+     * @throws MaskAlgorithmInitializationException mask algorithm initialization exception
+     */
+    public static void checkNonEmptyStringConfig(final String nonEmptyStringConfigValue, final String nonEmptyStringConfigKey, final String maskType) {
+        if (nonEmptyStringConfigValue.isEmpty()) {

Review Comment:
   Here it can be refactored like this:
   ```java
     /**
      * Check single char config.
      *
      * @param props props
      * @param singleCharConfigKey single char config key
      * @param maskType mask type
      * @throws MaskAlgorithmInitializationException mask algorithm initialization exception
      */
     public static void checkSingleCharConfig(final Properties props, final String singleCharConfigKey, final String maskType) {
         ShardingSpherePreconditions.checkState(props.containsKey(singleCharConfigKey),
                 () -> new MaskAlgorithmInitializationException(maskType, String.format("%s can not be null", singleCharConfigKey)));
         ShardingSpherePreconditions.checkState(1 == props.getProperty(singleCharConfigKey).length(),
                 () -> new MaskAlgorithmInitializationException(maskType, String.format("%s's length must be one", singleCharConfigKey)));
     }
   ```



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