Randgalt commented on a change in pull request #366: URL: https://github.com/apache/curator/pull/366#discussion_r424856746
########## File path: curator-framework/src/main/java/org/apache/curator/framework/imps/ProtectedUtils.java ########## @@ -0,0 +1,95 @@ +/** + * 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.curator.framework.imps; + +import java.util.UUID; + +import org.apache.curator.framework.api.CreateBuilderMain; + +/** + * Utility class to handle ZNode names when using {@link CreateBuilderMain#withProtection()} + */ +public final class ProtectedUtils { + + private ProtectedUtils() { + throw new RuntimeException("Protected Utils is a helper class"); + } + + /** + * First 3 characters in the prefix on ZNode names when using {@link CreateBuilderMain#withProtection()} + */ + public static final String PROTECTED_PREFIX = "_c_"; + + /** + * Last character used in the prefix on ZNode names when using {@link CreateBuilderMain#withProtection()} + */ + public static final char PROTECTED_SEPARATOR = '-'; + + /** + * Prefix length on ZNode name when using {@link #withProtection()} + */ + public static final int PROTECTED_PREFIX_WITH_UUID_LENGTH = + PROTECTED_PREFIX.length() + + 36 // UUID canonical text representation produced by {@link UUID#toString()} + + 1; // Separator length + + /** + * Provides a prefix to be appended to a ZNode name when protected. The method assumes that the provided string + * adjusts to the required format + * + * @param protectedId canonical text representation of a UUID + * @return string that concatenates {@value #PROTECTED_PREFIX}, the given id and {@value #PROTECTED_SEPARATOR} + */ + static String getProtectedPrefix(final String protectedId) Review comment: > Any particular reason? I get frustrated with other libraries when I want to use something (for debugging, etc.) and it's not public. Any reason not to make this public? ---------------------------------------------------------------- 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: [email protected]
