Hangleton commented on code in PR #13240: URL: https://github.com/apache/kafka/pull/13240#discussion_r1129710408
########## clients/src/main/java/org/apache/kafka/common/TopicIdAndNameBiMapping.java: ########## @@ -0,0 +1,91 @@ +/* + * 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.kafka.common; + +import org.apache.kafka.common.errors.InvalidTopicException; + +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; +import java.util.Optional; + +/** + * Encapsulates the mapping between topic names and ids assuming a 1:1 relationship between + * a name and an id. + * <p></p> + * Note that this class intends to be used for the (reverse) lookup of topic IDs/names, but + * not to characterize the set of topics which are known by a client. Use the + * {@link org.apache.kafka.clients.MetadataCache} for that purpose. + */ +public class TopicIdAndNameBiMapping { + private final Map<String, Uuid> topicIds; + private final Map<Uuid, String> topicNames; + + /** + * A mapping which universe of topic ids and names is captured from the input map. The reverse association + * between a topic ID and a topic name is computed by this method. If there are more than one topic name + * resolving to the same topic ID, an {@link InvalidTopicException} is thrown. + */ + public static TopicIdAndNameBiMapping fromTopicIds(Map<String, Uuid> topicIds) { Review Comment: Maybe `TopicIdAndNameBiMap`? -- 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: jira-unsubscr...@kafka.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org