mchades commented on code in PR #5791:
URL: https://github.com/apache/gravitino/pull/5791#discussion_r1879506799


##########
core/src/main/java/org/apache/gravitino/connector/WildcardPropertiesMetadata.java:
##########
@@ -0,0 +1,175 @@
+/*
+ * 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.gravitino.connector;
+
+import com.google.common.base.Preconditions;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import java.util.stream.Collectors;
+import org.apache.gravitino.authorization.AuthorizationPropertiesMetadata;
+
+/**
+ * WildcardPropertiesMeta is a metadata interface for defining wildcard 
properties in the properties
+ * metadata. <br>
+ * <br>
+ * WildcardPropertiesMetadata interface defines: <br>
+ * Prefix.Wildcard = "WildcardValue1,WildcardValue2" <br>
+ * Prefix.*.properties-key1 = "" <br>
+ * Prefix.*.properties-key2 = "" <br>
+ * NOTE: Prefix name support multiple segment, separated by dot. for example: 
"a1.b1.c1" <br>
+ * NOTE: Suffix properties-key{N} support multiple segment, separated by dot. 
for example:
+ * "x1.y1.z1" <br>
+ * <br>
+ * Use define a WildcardPropertiesMetadata object: <br>
+ * a1.b1.c1.Wildcard = "WildcardValue1,WildcardValue2" <br>
+ * a1.b1.c1.{WildcardValue1}.x1.y1.z1 = "WildcardValue1 property value" <br>
+ * a1.b1.c1.{WildcardValue1}.x1.y2.z2 = "WildcardValue1 property value" <br>
+ * a1.b1.c1.{WildcardValue1}.x1.y2.z3 = "WildcardValue1 property value" <br>
+ * a1.b1.c1.{WildcardValue2}.x1.y1.z1 = "WildcardValue2 property value" <br>
+ * a1.b1.c1.{WildcardValue2}.x1.y2.z2 = "WildcardValue2 property value" <br>
+ * a1.b1.c1.{WildcardValue2}.x1.y2.z3 = "WildcardValue2 property value" <br>
+ * <br>
+ * Configuration Example: {@link AuthorizationPropertiesMetadata}, <br>
+ * The Prefix is "authorization.chain", <br>
+ * The Wildcard is "plugins" <br>
+ * "authorization.chain.plugins" = "hive1,hdfs1" <br>
+ * "authorization.chain.hive1.provider" = "ranger"; <br>
+ * "authorization.chain.hive1.catalog-provider" = "hive"; <br>
+ * "authorization.chain.hive1.ranger.auth.type" = "simple"; <br>
+ * "authorization.chain.hive1.ranger.admin.url" = "http://localhost:6080";; <br>
+ * "authorization.chain.hive1.ranger.username" = "admin"; <br>
+ * "authorization.chain.hive1.ranger.password" = "admin"; <br>
+ * "authorization.chain.hive1.ranger.service.name" = "hiveDev"; <br>
+ * "authorization.chain.hdfs1.provider" = "ranger"; <br>
+ * "authorization.chain.hdfs1.catalog-provider" = "hadoop"; <br>
+ * "authorization.chain.hdfs1.ranger.auth.type" = "simple"; <br>
+ * "authorization.chain.hdfs1.ranger.admin.url" = "http://localhost:6080";; <br>
+ * "authorization.chain.hdfs1.ranger.username" = "admin"; <br>
+ * "authorization.chain.hdfs1.ranger.password" = "admin"; <br>
+ * "authorization.chain.hdfs1.ranger.service.name" = "hdfsDev"; <br>
+ */
+public interface WildcardPropertiesMetadata {
+  String WILDCARD = "*";
+  String WILDCARD_CONFIG_VALUES_SPLITTER = ",";
+
+  /** The prefix name */
+  String prefixName();
+
+  /** The WildcardNode define name */
+  String wildcardName();
+
+  /** The `Prefix.Wildcard` properties key name */
+  default String wildcardPropertyKey() {
+    return String.format("%s.%s", prefixName(), wildcardName());
+  }
+
+  /** Get the property value by wildcard value and property key */
+  default String getPropertyValue(String wildcardValue, String propertyKey) {
+    return String.format("%s.%s.%s", prefixName(), wildcardValue, propertyKey);
+  }
+
+  /**
+   * Validate the wildcard properties in the properties metadata.
+   *
+   * @param propertiesMetadata the properties metadata
+   * @param properties the properties
+   * @throws IllegalArgumentException if the wildcard properties are not valid
+   */
+  static void validate(PropertiesMetadata propertiesMetadata, Map<String, 
String> properties)
+      throws IllegalArgumentException {
+    // Get all wildcard properties from PropertiesMetadata
+    List<String> wildcardProperties =
+        propertiesMetadata.propertyEntries().keySet().stream()
+            .filter(propertiesMetadata::isWildcardProperty)
+            .collect(Collectors.toList());
+    if (wildcardProperties.size() > 0) {

Review Comment:
   suggest use:
   ```java
   if (wildcardProperties.isEmpty()) {
         return;
       }
   ```



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