private Class < ? > defineMapClass ( ParameterizedTypeName mapTypeName ) { if ( mapTypeName . rawType . toString ( ) . startsWith ( Map . class . getCanonicalName ( ) ) ) { // it's a list return HashMap . class ; } else if ( mapTypeName . rawType . toString ( ) . startsWith ( SortedMap . class . getCanonicalName ( ) ) ) { return TreeMap . class ; } try { return Class . forName ( mapTypeName . rawType . toString ( ) ) ; } catch ( ClassNotFoundException e ) { e . printStackTrace ( ) ; return null ; } }
Define map class .