@Test( expected = IllegalArgumentException.class ) public void toEnumValueNullString() { NameUtils.toEnumValue( ChronoUnit.class, new Object() { @Override public String toString() { return null; } } ); }
@Nonnull public static <T extends Enum<T>> T toEnumValue( @Nonnull Class<T> enumClass, @Nullable Object value ) throws IllegalArgumentException { final String stringValue = toEnumName( value ); if ( stringValue == null ) { throw new IllegalArgumentException( "Null enum values are not allowed" ); } return Enum.valueOf( enumClass, stringValue ); }
NameUtils { @Nonnull public static <T extends Enum<T>> T toEnumValue( @Nonnull Class<T> enumClass, @Nullable Object value ) throws IllegalArgumentException { final String stringValue = toEnumName( value ); if ( stringValue == null ) { throw new IllegalArgumentException( "Null enum values are not allowed" ); } return Enum.valueOf( enumClass, stringValue ); } }
NameUtils { @Nonnull public static <T extends Enum<T>> T toEnumValue( @Nonnull Class<T> enumClass, @Nullable Object value ) throws IllegalArgumentException { final String stringValue = toEnumName( value ); if ( stringValue == null ) { throw new IllegalArgumentException( "Null enum values are not allowed" ); } return Enum.valueOf( enumClass, stringValue ); } private  NameUtils(); }
NameUtils { @Nonnull public static <T extends Enum<T>> T toEnumValue( @Nonnull Class<T> enumClass, @Nullable Object value ) throws IllegalArgumentException { final String stringValue = toEnumName( value ); if ( stringValue == null ) { throw new IllegalArgumentException( "Null enum values are not allowed" ); } return Enum.valueOf( enumClass, stringValue ); } private  NameUtils(); @Nullable static String toClassName( @Nullable Object value ); @Nonnull static T toEnumValue( @Nonnull Class<T> enumClass, @Nullable Object value ); @Nullable static T toEnumValue( @Nonnull Class<T> enumClass, @Nullable String value ); @Nullable static String toEnumName( @Nullable Object value ); }
NameUtils { @Nonnull public static <T extends Enum<T>> T toEnumValue( @Nonnull Class<T> enumClass, @Nullable Object value ) throws IllegalArgumentException { final String stringValue = toEnumName( value ); if ( stringValue == null ) { throw new IllegalArgumentException( "Null enum values are not allowed" ); } return Enum.valueOf( enumClass, stringValue ); } private  NameUtils(); @Nullable static String toClassName( @Nullable Object value ); @Nonnull static T toEnumValue( @Nonnull Class<T> enumClass, @Nullable Object value ); @Nullable static T toEnumValue( @Nonnull Class<T> enumClass, @Nullable String value ); @Nullable static String toEnumName( @Nullable Object value );  }