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


##########
features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/MaskAlgorithmPropsChecker.java:
##########
@@ -72,13 +70,41 @@ public static void checkAtLeastOneCharConfig(final 
Properties props, final Strin
      * @throws MaskAlgorithmInitializationException mask algorithm 
initialization exception
      */
     public static void checkIntegerTypeConfig(final Properties props, final 
String integerTypeConfigKey, final String maskType) {
-        if (!props.containsKey(integerTypeConfigKey)) {
-            throw new MaskAlgorithmInitializationException(maskType, 
String.format("%s can not be null", integerTypeConfigKey));
-        }
+        
ShardingSpherePreconditions.checkState(props.containsKey(integerTypeConfigKey),
+                () -> new MaskAlgorithmInitializationException(maskType, 
String.format("%s can not be null", integerTypeConfigKey)));
         try {
             Integer.parseInt(props.getProperty(integerTypeConfigKey));
         } catch (final NumberFormatException ex) {
             throw new MaskAlgorithmInitializationException(maskType, 
String.format("%s must be a valid integer number", integerTypeConfigKey));
         }
     }
+    
+    /**
+     * Check required property config.
+     *
+     * @param props props
+     * @param requiredPropertyConfigKey required property config key
+     * @param maskType mask type
+     * @throws MaskAlgorithmInitializationException mask algorithm 
initialization exception
+     */
+    public static void checkRequiredPropertyConfig(final Properties props, 
final String requiredPropertyConfigKey, final String maskType) {
+        
ShardingSpherePreconditions.checkState(props.containsKey(requiredPropertyConfigKey),
+                () -> new MaskAlgorithmInitializationException(maskType, 
String.format("%s is required", requiredPropertyConfigKey)));
+    }
+    
+    /**
+     * Check required property config.
+     *
+     * @param props props
+     * @param positiveIntegerTypeConfigKey positive integer type config key
+     * @param maskType mask type
+     * @throws MaskAlgorithmInitializationException mask algorithm 
initialization exception
+     */
+    public static void checkPositiveIntegerConfig(final Properties props, 
final String positiveIntegerTypeConfigKey, final String maskType) {

Review Comment:
   So this method should first check `containsKey`, then check `parseInt` is 
correct, and then check `positive`



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