Mmuzaf commented on code in PR #2133: URL: https://github.com/apache/cassandra/pull/2133#discussion_r1148123089
########## src/java/org/apache/cassandra/config/registry/PrimitiveUnaryConverter.java: ########## @@ -0,0 +1,84 @@ +/* + * 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.cassandra.config.registry; + +import javax.annotation.Nonnull; + +import org.apache.cassandra.exceptions.ConfigurationException; + +/** + * Converter do type conversion from the specified Object value to the given {@code T}. If the class is + * a primitive type (e.g. Boolean.TYPE, Long.TYPE etc), the value returned will use the corresponding + * wrapper type (Long.class, Boolean.class, etc). + * + * @see TypeConverter + * @see org.apache.cassandra.config.StringConverters + */ +public class PrimitiveUnaryConverter +{ + private static Object to(Class<?> cls, @Nonnull Object value) Review Comment: We have a collection of `Config` properties. Some of these properties can be of a `boolean` type, while the others are of a `Boolean` (or we can take any pair from primitives and their wrappers). We always return a wrapper object from the `Registry` when the `<T> T get(Class<T> cls, String name)` method is called, regardless of whether the primitive or wrapper for the property is set. For both of the cases primitive or wrapper, we have to be sure that we can cast to the right type when the `get` method is called - and this is the issue hiding under the hood and the purpose of this method. -- 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] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]

