public static void ensureValidBindAddresses ( List < Protocol > protocols ) throws Exception { for ( Protocol protocol : protocols ) { String protocolName = protocol . getName ( ) ; //traverse class hierarchy and find all annotated fields and add them to the list if annotated Field [ ] fields = Util . getAllDeclaredFieldsWithAnnotations ( protocol . getClass ( ) , LocalAddress . class ) ; for ( int i = 0 ; i < fields . length ; i ++ ) { Object val = getValueFromProtocol ( protocol , fields [ i ] ) ; if ( val == null ) continue ; if ( ! ( val instanceof InetAddress ) ) throw new Exception ( "field " + protocolName + "." + fields [ i ] . getName ( ) + " is not an InetAddress" ) ; Util . checkIfValidAddress ( ( InetAddress ) val , protocolName ) ; } } }
Makes sure that all fields annotated with