garydgregory commented on code in PR #216: URL: https://github.com/apache/commons-cli/pull/216#discussion_r1469712017
########## src/main/java/org/apache/commons/cli/TypeHandler.java: ########## @@ -19,29 +19,114 @@ Licensed to the Apache Software Foundation (ASF) under one or more import java.io.File; import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.net.MalformedURLException; +import java.math.BigDecimal; +import java.math.BigInteger; import java.net.URL; +import java.nio.file.Path; import java.util.Date; +import java.util.HashMap; +import java.util.Map; /** - * This is a temporary implementation. TypeHandler will handle the pluggableness of OptionTypes and it will direct all - * of these types of conversion functionalities to ConvertUtils component in Commons already. BeanUtils I think. + * TypeHandler will handle the pluggable conversion and verification of + * Option types. It handles the mapping of classes to bot converters and verifiers. + * It provides the default conversion and verification methods when converters and verifiers + * are not explicitly set. + * <p> + * If Options are serialized and deserialized their converters and verifiers will revert to the + * defaults defined in this class. To correctly de-serialize Options with custom converters and/or + * verifiers, using the default serialization methods, this class should be properly configured with the custom + * converters and verifiers for the specific class. + * </p> */ public class TypeHandler { + + /** Value of hex conversion of strings */ + private static final int HEX_RADIX = 16; + + /** Map of classes to converters. */ + private static Map<Class<?>, Converter<?>> converterMap = new HashMap<>(); + + static { + resetConverters(); + } + + /** + * Resets the registered Converters to the default state. + * @since 1.7.0 + */ + public static void resetConverters() { + converterMap.clear(); + converterMap.put(Object.class, Converter.OBJECT); Review Comment: Hi @Claudenw, We have a mix of using constants and expressions to define this map. I think it would be better to do it one way or another: Use all constants or use all expressions. The simplest would be to inline the constants from `Converter` and decrease the new public footprint. Alternatively, to keep constants we could make them package-private in a new or existing class. Any thoughts on this? -- 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: issues-unsubscr...@commons.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org