roryqi commented on code in PR #12162:
URL: https://github.com/apache/gravitino/pull/12162#discussion_r3655202935


##########
api/src/main/java/org/apache/gravitino/tag/TagValue.java:
##########
@@ -0,0 +1,114 @@
+/*
+ * 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.tag;
+
+import com.google.common.base.Preconditions;
+import java.util.Objects;
+import java.util.Optional;
+import javax.annotation.Nullable;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.gravitino.annotation.Evolving;
+
+/** Represents one tag assignment value in tag association requests. */
+@Evolving
+public final class TagValue {
+
+  private final String name;
+
+  @Nullable private final String value;
+
+  private TagValue(String name, @Nullable String value) {
+    this.name = name;
+    this.value = value;
+  }

Review Comment:
   `TagValue` is not intended to be the Jackson DTO. It is the public API value 
object. The common/server PR uses a request DTO wrapper for the JSON shape and 
converts between `{name, value}` and `TagValue`, so keeping `TagValue` 
immutable with a private constructor is intentional.



##########
api/src/main/java/org/apache/gravitino/tag/TagOperations.java:
##########
@@ -70,6 +70,31 @@ public interface TagOperations {
   Tag createTag(String name, String comment, Map<String, String> properties)
       throws TagAlreadyExistsException;
 
+  /**
+   * Create a tag under a metalake with an assignment value constraint.
+   *
+   * @param name The name of the tag.
+   * @param comment The comment of the tag.
+   * @param properties The properties of the tag.
+   * @param valueConstraint The assignment value constraint of the tag.
+   * @return The created tag.
+   * @throws TagAlreadyExistsException If the tag already exists.
+   * @throws UnsupportedOperationException If non-default value constraints 
are not supported.
+   */
+  default Tag createTag(
+      String name,
+      String comment,
+      Map<String, String> properties,
+      TagValueConstraint valueConstraint)
+      throws TagAlreadyExistsException {
+    if (valueConstraint == null || 
TagValueConstraint.anyValue().equals(valueConstraint)) {
+      return createTag(name, comment, properties);
+    }

Review Comment:
   Same intent here: the 3-arg createTag has no value constraint, so it maps to 
the unrestricted constraint (`anyValue`). `withoutValues()` is a stricter new 
constraint and should only be supported by implementations that override this 
overload.



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