code: private Object marshallParameterAsPrimitive(Object parameter) {
          Map<String, Object> primitiveWrapper = Collections.singletonMap("wrapped", parameter);
          BsonDocument document = marshaller.marshall(primitiveWrapper);
          return document.toDBObject().get("wrapped");
      }
docs: The object may have been serialized to a primitive type with a
  custom serializer, so try again after wrapping as an object property.
  We do this trick only as a falllback since it causes Jackson to consider the parameter
  as "Object" and thus ignore any annotations that may exist on its actual class.