public static Map<String, Object> newMapInstance(Class<?> mapClass) {
    if (mapClass == null || mapClass.isAssignableFrom(ArrayMap.class)) {
      return ArrayMap.create();
    }
    if (mapClass.isAssignableFrom(TreeMap.class)) {
      return new TreeMap<String, Object>();
    }
    @SuppressWarnings("unchecked")
    Map<String, Object> result = (Map<String, Object>) Types.newInstance(mapClass);
    return result;
  }
public static Map < String , Object > newMapInstance ( Class < ? > mapClass ) { if ( mapClass == null || mapClass . isAssignableFrom ( ArrayMap . class ) ) { return ArrayMap . create ( ) ; } if ( mapClass . isAssignableFrom ( TreeMap . class ) ) { return new TreeMap < String , Object > ( ) ; } @ SuppressWarnings ( "unchecked" ) Map < String , Object > result = ( Map < String , Object > ) Types . newInstance ( mapClass ) ; return result ; }
Returns a new instance of a map based on the given field class.

<p>Creates a new map instance specified for the first input map class that matches as follows:

<ul>
<li>{@code null} or assignable from {@link ArrayMap} (like {@link Map} or {@link Object}):
returns an {@link ArrayMap}
<li>assignable from {@link TreeMap} (like {@link SortedMap}): returns a {@link TreeMap}
<li>else: calls {@link Types#newInstance(Class)}
</ul>

@param mapClass field class
@throws ClassCastException if result is does not extend {@link Map}