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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]