public void add ( T method ) { // check for overridden method if ( isOverrideMethod ( method ) ) { return ; } // Add to the list of managed methods _methods . put ( method . getName ( ) + method . getArgTypes ( ) , method ) ; // Ensure that all added methods have a unique index Object nameValue = _nameMap . get ( method . getName ( ) ) ; if ( nameValue == null ) { // first method with this name, considered unique (for now) _nameMap . put ( method . getName ( ) , method ) ; } else { int nextIndex ; if ( nameValue instanceof AptMethod ) { // 2nd method with this name, add index to original and start indexing ( ( AptMethod ) nameValue ) . setIndex ( 0 ) ; nextIndex = 1 ; } else { // 3rd (or later) method with this name, continue indexing nextIndex = ( ( Integer ) nameValue ) . intValue ( ) ; } method . setIndex ( nextIndex ++ ) ; _nameMap . put ( method . getName ( ) , nextIndex ) ; } }
Adds a new method to the list . Also detects overloaded methods and ensures that they will receive a unique index value .