private void tryRegisterJava8Optionals ( ) { try { loadType ( "java.util.OptionalInt" ) ; @ SuppressWarnings ( "unchecked" ) Class < ? > cls1 = ( Class < TypedStringConverter < ? > > ) loadType ( "org.joda.convert.OptionalIntStringConverter" ) ; TypedStringConverter < ? > conv1 = ( TypedStringConverter < ? > ) cls1 . getDeclaredConstructor ( ) . newInstance ( ) ; registered . put ( conv1 . getEffectiveType ( ) , conv1 ) ; @ SuppressWarnings ( "unchecked" ) Class < ? > cls2 = ( Class < TypedStringConverter < ? > > ) loadType ( "org.joda.convert.OptionalLongStringConverter" ) ; TypedStringConverter < ? > conv2 = ( TypedStringConverter < ? > ) cls2 . getDeclaredConstructor ( ) . newInstance ( ) ; registered . put ( conv2 . getEffectiveType ( ) , conv2 ) ; @ SuppressWarnings ( "unchecked" ) Class < ? > cls3 = ( Class < TypedStringConverter < ? > > ) loadType ( "org.joda.convert.OptionalDoubleStringConverter" ) ; TypedStringConverter < ? > conv3 = ( TypedStringConverter < ? > ) cls3 . getDeclaredConstructor ( ) . newInstance ( ) ; registered . put ( conv3 . getEffectiveType ( ) , conv3 ) ; } catch ( Throwable ex ) { if ( LOG ) { System . err . println ( "tryRegisterOptionals: " + ex ) ; } } }
Tries to register the Java 8 optional classes .