mumrah commented on code in PR #14628: URL: https://github.com/apache/kafka/pull/14628#discussion_r1385786809
########## metadata/src/main/java/org/apache/kafka/metadata/properties/MetaPropertiesVersion.java: ########## @@ -0,0 +1,71 @@ +/* + * 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.metadata.properties; + +/** + * The version of a meta.properties file. + */ +public enum MetaPropertiesVersion { + V0(0), + V1(1); + + private final int number; + + public static MetaPropertiesVersion fromNumberString(String numberString) { + int number; + try { + number = Integer.parseInt(numberString.trim()); + } catch (NumberFormatException e) { + throw new RuntimeException("Invalid meta.properties version string '" + + numberString + "'"); + } + return fromNumber(number); + } + + public static MetaPropertiesVersion fromNumber(int number) { + switch (number) { + case 0: return V0; + case 1: return V1; + default: throw new RuntimeException("Unknown meta.properties version number " + number); + } + } + + MetaPropertiesVersion(int number) { + this.number = number; + } + + public int number() { + return number; + } + + public String numberString() { + return "" + number; Review Comment: Just curious, why not use `Integer.toString` here? Is this string coercion more efficient or something? ########## metadata/src/main/java/org/apache/kafka/metadata/properties/MetaPropertiesVersion.java: ########## @@ -0,0 +1,71 @@ +/* + * 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.metadata.properties; + +/** + * The version of a meta.properties file. + */ +public enum MetaPropertiesVersion { + V0(0), Review Comment: Should we document the differences between v0 and v1 here? -- 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