public Map < String , String > parseSignatureForGenerics ( final String signature , final boolean isInterface ) { if ( signature == null ) { return Collections . emptyMap ( ) ; } final Map < String , String > genericsMap = new HashMap <> ( ) ; SignatureReader sr = new SignatureReader ( signature ) ; StringBuilder sb = new StringBuilder ( ) ; TraceSignatureVisitor v = new TraceSignatureVisitor ( sb , isInterface ) { String genericName ; @ Override public void visitFormalTypeParameter ( final String name ) { genericName = name ; super . visitFormalTypeParameter ( name ) ; } @ Override public void visitClassType ( final String name ) { if ( genericName != null ) { genericsMap . put ( genericName , ' ' + name + ' ' ) ; genericName = null ; } super . visitClassType ( name ) ; } } ; sr . accept ( v ) ; return genericsMap ; }
Parses signature for generic information and returns a map where key is generic name and value is raw type . Returns an empty map if signature does not define any generics .