gjacoby126 commented on a change in pull request #2707:
URL: https://github.com/apache/hbase/pull/2707#discussion_r532759903



##########
File path: 
hbase-common/src/main/java/org/apache/hadoop/hbase/TagBuilderFactory.java
##########
@@ -0,0 +1,105 @@
+/**
+ * Copyright The Apache Software Foundation
+ *
+ * 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.hadoop.hbase;
+
+import java.nio.ByteBuffer;
+import org.apache.yetus.audience.InterfaceAudience;
+
+/**
+ * Factory to create Tags.
+ */
+@InterfaceAudience.LimitedPrivate(HBaseInterfaceAudience.COPROC)
+public final class TagBuilderFactory {
+
+  public static TagBuilder create(TagBuilderType type) {
+    switch (type) {
+      case ARRAY_BACKED:
+        return new ArrayTagBuilderImpl();
+      case BYTE_BUFFER_BACKED:
+        return new ByteBufferTagBuilderImpl();
+      default:
+        throw new UnsupportedOperationException("The type:" + type + " is 
unsupported");
+    }
+  }
+}
+
+/**
+ * Builder implementation to create {@link ArrayBackedTag}
+ */
+class ArrayTagBuilderImpl implements TagBuilder {
+  private byte[] tagBytes;
+  private byte tagType;
+
+  @Override
+  public TagBuilder setType(byte type) {
+    this.tagType = type;
+    return this;
+  }
+
+  @Override
+  public TagBuilder setTagValue(byte[] tagBytes) {
+    this.tagBytes = tagBytes;
+    return this;
+  }
+
+  @Override
+  public TagBuilder setTagByteBuffer(ByteBuffer byteBuffer) {
+    throw new UnsupportedOperationException(
+      "Tag is backed by an Array. Use setTagValue instead");
+  }
+
+  @Override
+  public Tag build() {
+    ArrayBackedTag tag = new ArrayBackedTag(tagType, tagBytes);
+    return tag;
+  }
+}
+
+/**
+ * Builder implementation to create {@link ByteBufferTag}
+ */
+class ByteBufferTagBuilderImpl implements TagBuilder {
+  private byte tagType;
+  private ByteBuffer tagBuffer;
+  @Override
+  public TagBuilder setType(byte type) {

Review comment:
       how about setTagType? I was initially confused when reading the test if 
this was for setting the type of tag (e.g array or byte buffered) or the type 
field of the tag itself. 




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

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to