docs: @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());
              }
          }
      }