@@ -28,19 +28,19 @@ Licensed to the Apache Software Foundation (ASF) under one or more
2828import java .util .Map ;
2929
3030/**
31- * TypeHandler will handle the pluggable conversion and verification of
31+ * TypeHandler will handle the pluggable conversion and verification of
3232 * Option types. It handles the mapping of classes to bot converters and verifiers.
3333 * It provides the default conversion and verification methods when converters and verifiers
3434 * are not explicitly set.
3535 * <p>
36- * If Options are serialized and deserialized their converters and verifiers will revert to the
36+ * If Options are serialized and deserialized their converters and verifiers will revert to the
3737 * defaults defined in this class. To correctly de-serialize Options with custom converters and/or
3838 * verifiers, using the default serialization methods, this class should be properly configured with the custom
3939 * converters and verifiers for the specific class.
4040 * </p>
4141 */
4242public class TypeHandler {
43-
43+
4444 /** Value of hex conversion of strings */
4545 private static final int HEX_RADIX = 16 ;
4646
@@ -50,7 +50,7 @@ public class TypeHandler {
5050 static {
5151 resetConverters ();
5252 }
53-
53+
5454 /**
5555 * Returns the class whose name is {@code className}.
5656 *
@@ -63,7 +63,7 @@ public class TypeHandler {
6363 public static Class <?> createClass (final String className ) throws ParseException {
6464 return createValue (className , Class .class );
6565 }
66-
66+
6767 /**
6868 * Returns the date represented by {@code str}.
6969 * <p>
@@ -77,7 +77,7 @@ public static Class<?> createClass(final String className) throws ParseException
7777 public static Date createDate (final String str ) {
7878 try {
7979 return createValue (str , Date .class );
80- } catch (ParseException e ) {
80+ } catch (final ParseException e ) {
8181 throw new RuntimeException (e );
8282 }
8383 }
@@ -93,7 +93,7 @@ public static Date createDate(final String str) {
9393 public static File createFile (final String str ) {
9494 try {
9595 return createValue (str , File .class );
96- } catch (ParseException e ) {
96+ } catch (final ParseException e ) {
9797 throw new RuntimeException (e );
9898 }
9999 }
@@ -166,7 +166,7 @@ public static URL createURL(final String str) throws ParseException {
166166 public static <T > T createValue (final String str , final Class <T > clazz ) throws ParseException {
167167 try {
168168 return (T ) getConverter (clazz ).apply (str );
169- } catch (Exception e ) {
169+ } catch (final Exception e ) {
170170 throw ParseException .wrap (e );
171171 }
172172 }
@@ -192,7 +192,7 @@ public static Object createValue(final String str, final Object obj) throws Pars
192192 * @since 1.7.0
193193 */
194194 public static Converter <?> getConverter (final Class <?> clazz ) {
195- Converter <?> converter = converterMap .get (clazz );
195+ final Converter <?> converter = converterMap .get (clazz );
196196 return converter == null ? Converter .DEFAULT : converter ;
197197 }
198198
@@ -218,9 +218,9 @@ public static FileInputStream openFile(final String str) throws ParseException {
218218 }
219219
220220 /**
221- * Registers a Converter for a Class. If @code converter} is null registration is cleared for {@code clazz}, and
221+ * Registers a Converter for a Class. If @code converter} is null registration is cleared for {@code clazz}, and
222222 * no converter will be used in processing.
223- *
223+ *
224224 * @param clazz the Class to register the Converter and Verifier to.
225225 * @param converter The Converter to associate with Class. May be null.
226226 * @since 1.7.0
@@ -246,20 +246,19 @@ public static void resetConverters() {
246246 converterMap .put (Path .class , Converter .PATH );
247247 converterMap .put (Number .class , Converter .NUMBER );
248248 converterMap .put (URL .class , Converter .URL );
249- converterMap .put (FileInputStream .class , s -> new FileInputStream ( s ) );
249+ converterMap .put (FileInputStream .class , FileInputStream :: new );
250250 converterMap .put (Long .class , Long ::parseLong );
251251 converterMap .put (Integer .class , Integer ::parseInt );
252252 converterMap .put (Short .class , Short ::parseShort );
253253 converterMap .put (Byte .class , Byte ::parseByte );
254254 converterMap .put (Character .class , s -> {
255255 if (s .startsWith ("\\ u" )) {
256256 return Character .toChars (Integer .parseInt (s .substring (2 ), HEX_RADIX ))[0 ];
257- } else {
258- return s .charAt (0 );
259- } });
257+ }
258+ return s .charAt (0 ); });
260259 converterMap .put (Double .class , Double ::parseDouble );
261260 converterMap .put (Float .class , Float ::parseFloat );
262- converterMap .put (BigInteger .class , s -> new BigInteger ( s ) );
263- converterMap .put (BigDecimal .class , s -> new BigDecimal ( s ) );
261+ converterMap .put (BigInteger .class , BigInteger :: new );
262+ converterMap .put (BigDecimal .class , BigDecimal :: new );
264263 }
265264}
0 commit comments