static public HashMap getErrorCodes ( Class clazz ) { HashMap map = new HashMap ( 23 ) ; // Use reflection to populte the erroCodeMap to have the reverse mapping // of error codes to symbolic names. Field flds [ ] = clazz . getDeclaredFields ( ) ; for ( int i = 0 ; i < flds . length ; i ++ ) { int mods = flds [ i ] . getModifiers ( ) ; if ( Modifier . isFinal ( mods ) && Modifier . isStatic ( mods ) && Modifier . isPublic ( mods ) ) { try { map . put ( flds [ i ] . get ( null ) , flds [ i ] . getName ( ) ) ; } catch ( Throwable t ) { // NOPMD // ignore this. } } } return map ; }
Return the codes that are defined on a subclass of our class .