@@ -919,67 +919,67 @@ private static class EnumTypeLocator
919
919
private final Field enumMapTypeField ;
920
920
921
921
private EnumTypeLocator () {
922
- //JDK uses following fields to store information about actual Enumeration
923
- // type for EnumSets, EnumMaps...
924
- enumSetTypeField = locateField (EnumSet .class , "elementType" , Class .class );
925
- enumMapTypeField = locateField (EnumMap .class , "elementType" , Class .class );
926
- }
922
+ //JDK uses following fields to store information about actual Enumeration
923
+ // type for EnumSets, EnumMaps...
924
+ enumSetTypeField = locateField (EnumSet .class , "elementType" , Class .class );
925
+ enumMapTypeField = locateField (EnumMap .class , "elementType" , Class .class );
926
+ }
927
927
928
- @ SuppressWarnings ("unchecked" )
929
- public Class <? extends Enum <?>> enumTypeFor (EnumSet <?> set )
930
- {
931
- if (enumSetTypeField != null ) {
932
- return (Class <? extends Enum <?>>) get (set , enumSetTypeField );
933
- }
934
- throw new IllegalStateException ("Can not figure out type for EnumSet (odd JDK platform?)" );
935
- }
928
+ @ SuppressWarnings ("unchecked" )
929
+ public Class <? extends Enum <?>> enumTypeFor (EnumSet <?> set )
930
+ {
931
+ if (enumSetTypeField != null ) {
932
+ return (Class <? extends Enum <?>>) get (set , enumSetTypeField );
933
+ }
934
+ throw new IllegalStateException ("Can not figure out type for EnumSet (odd JDK platform?)" );
935
+ }
936
936
937
- @ SuppressWarnings ("unchecked" )
938
- public Class <? extends Enum <?>> enumTypeFor (EnumMap <?,?> set )
937
+ @ SuppressWarnings ("unchecked" )
938
+ public Class <? extends Enum <?>> enumTypeFor (EnumMap <?,?> set )
939
939
{
940
- if (enumMapTypeField != null ) {
941
- return (Class <? extends Enum <?>>) get (set , enumMapTypeField );
942
- }
943
- throw new IllegalStateException ("Can not figure out type for EnumMap (odd JDK platform?)" );
940
+ if (enumMapTypeField != null ) {
941
+ return (Class <? extends Enum <?>>) get (set , enumMapTypeField );
942
+ }
943
+ throw new IllegalStateException ("Can not figure out type for EnumMap (odd JDK platform?)" );
944
944
}
945
945
946
- private Object get (Object bean , Field field )
947
- {
948
- try {
949
- return field .get (bean );
950
- } catch (Exception e ) {
951
- throw new IllegalArgumentException (e );
952
- }
953
- }
946
+ private Object get (Object bean , Field field )
947
+ {
948
+ try {
949
+ return field .get (bean );
950
+ } catch (Exception e ) {
951
+ throw new IllegalArgumentException (e );
952
+ }
953
+ }
954
954
955
- private static Field locateField (Class <?> fromClass , String expectedName , Class <?> type )
956
- {
957
- Field found = null ;
958
- // First: let's see if we can find exact match:
959
- Field [] fields = getDeclaredFields (fromClass );
960
- for (Field f : fields ) {
961
- if (expectedName .equals (f .getName ()) && f .getType () == type ) {
962
- found = f ;
963
- break ;
964
- }
965
- }
966
- // And if not, if there is just one field with the type, that field
967
- if (found == null ) {
955
+ private static Field locateField (Class <?> fromClass , String expectedName , Class <?> type )
956
+ {
957
+ Field found = null ;
958
+ // First: let's see if we can find exact match:
959
+ Field [] fields = getDeclaredFields (fromClass );
968
960
for (Field f : fields ) {
969
- if (f .getType () == type ) {
970
- // If more than one, can't choose
971
- if (found != null ) return null ;
961
+ if (expectedName .equals (f .getName ()) && f .getType () == type ) {
972
962
found = f ;
963
+ break ;
973
964
}
974
965
}
975
- }
976
- if (found != null ) { // it's non-public, need to force accessible
977
- try {
978
- found .setAccessible (true );
979
- } catch (Throwable t ) { }
980
- }
981
- return found ;
982
- }
966
+ // And if not, if there is just one field with the type, that field
967
+ if (found == null ) {
968
+ for (Field f : fields ) {
969
+ if (f .getType () == type ) {
970
+ // If more than one, can't choose
971
+ if (found != null ) return null ;
972
+ found = f ;
973
+ }
974
+ }
975
+ }
976
+ if (found != null ) { // it's non-public, need to force accessible
977
+ try {
978
+ found .setAccessible (true );
979
+ } catch (Throwable t ) { }
980
+ }
981
+ return found ;
982
+ }
983
983
}
984
984
985
985
/*
0 commit comments