code: @SuppressWarnings("deprecation")
      public static <T> T toEntity(final Class<T> targetClass, final Document doc) {
          checkTargetClass(targetClass);
  
          if (Map.class.isAssignableFrom(targetClass)) {
              // return (T) new LinkedHashMap<>(doc);
              if (targetClass.isAssignableFrom(doc.getClass())) {
                  return (T) doc;
              } else {
                  final Map<String, Object> map = (Map<String, Object>) N.newInstance(targetClass);
                  map.putAll(doc);
                  return (T) map;
              }
          }
  
          final Method idSetMethod = getObjectIdSetMethod(targetClass);
          final Class<?> parameterType = idSetMethod == null ? null : idSetMethod.getParameterTypes()[0];
          final Object objectId = doc.getObjectId(_ID);
          T entity = null;
  
          doc.remove(_ID);
  
          try {
              entity = Maps.map2Entity(targetClass, doc);
  
              if (objectId != null && parameterType != null) {
                  if (parameterType.isAssignableFrom(objectId.getClass())) {
                      ClassUtil.setPropValue(entity, idSetMethod, objectId);
                  } else if (parameterType.isAssignableFrom(String.class)) {
                      ClassUtil.setPropValue(entity, idSetMethod, objectId.toString());
                  } else {
                      ClassUtil.setPropValue(entity, idSetMethod, objectId);
                  }
              }
          } finally {
              doc.put(_ID, objectId);
          }
  
          if (N.isDirtyMarker(entity.getClass())) {
              ((DirtyMarker) entity).markDirty(false);
          }
  
          return entity;
      }
docs: The id in the specified <code>doc</code> will be set to the returned object if and only if the id is not null or empty and it's acceptable to the <code>targetClass</code>.
  
  @param targetClass an entity class with getter/setter method, <code>Map.class</code> or basic single value type(Primitive/String/Date...)
  @param doc
  @return