code: @SuppressWarnings("unchecked")
      public static <T> T asType(Map map, Class<T> clazz) {
          if (!(clazz.isInstance(map)) && clazz.isInterface() && !Traits.isTrait(clazz)) {
              return (T) Proxy.newProxyInstance(
                      clazz.getClassLoader(),
                      new Class[]{clazz},
                      new ConvertedMap(map));
          }
          try {
              return asType((Object) map, clazz);
          } catch (GroovyCastException ce) {
              try {
                  return (T) ProxyGenerator.INSTANCE.instantiateAggregateFromBaseClass(map, clazz);
              } catch (GroovyRuntimeException cause) {
                  throw new GroovyCastException("Error casting map to " + clazz.getName() +
                          ", Reason: " + cause.getMessage());
              }
          }
      }
docs: Coerces this map to the given type, using the map's keys as the public
  method names, and values as the implementation.  Typically the value
  would be a closure which behaves like the method implementation.
  
  @param map   this map
  @param clazz the target type
  @return a Proxy of the given type, which defers calls to this map's elements.
  @since 1.0