// Path: RosettaCore/src/main/java/com/hubspot/rosetta/RosettaBinder.java
// public enum RosettaBinder {
//   INSTANCE;
// 
//   public interface Callback {
//     void bind(String key, Object value);
//   }
// 
//   public void bind(String prefix, JsonNode node, Callback callback) {
//     for (Iterator<Entry<String, JsonNode>> iterator = node.fields(); iterator.hasNext(); ) {
//       Entry<String, JsonNode> field = iterator.next();
//       String key = prefix.isEmpty() ? field.getKey() : prefix + "." + field.getKey();
//       JsonNode value = field.getValue();
// 
//       if (value.isObject()) {
//         bind(key, value, callback);
//       } else if (value.isArray()) {
//         List<Object> elements = new ArrayList<>();
//         for (JsonNode element : value) {
//           elements.add(unwrapJsonValue(element));
//         }
// 
//         callback.bind(key, elements);
//       } else {
//         callback.bind(key, unwrapJsonValue(value));
//       }
//     }
//   }
// 
//   private Object unwrapJsonValue(JsonNode node) {
//     if (node.isNull()) {
//       return null;
//     } else if (node.isBoolean()) {
//       return node.booleanValue();
//     } else if (node.isBinary()) {
//       return ((BinaryNode) node).binaryValue();
//     } else if (node.isNumber()) {
//       return node.numberValue();
//     } else {
//       return node.asText();
//     }
//   }
// }


import com.fasterxml.jackson.databind.ObjectMapper;
import com.hubspot.rosetta.RosettaBinder;
import com.hubspot.rosetta.RosettaBinder.Callback;
import org.skife.jdbi.v2.SQLStatement;
import com.fasterxml.jackson.databind.JsonNode;
import org.skife.jdbi.v2.sqlobject.Binder;
package com.hubspot.rosetta.jdbi;



public enum RosettaJdbiBinder implements Binder<BindWithRosetta, Object> {
  INSTANCE;

  @Override
  public void bind(final SQLStatement<?> q, BindWithRosetta bind, Object arg) {
    ObjectMapper objectMapper = RosettaObjectMapperOverride.resolve(q.getContext());

    JsonNode node = objectMapper.valueToTree(arg);
    String prefix = bind.value();

    if (node.isValueNode() || node.isArray()) {
      node = objectMapper.createObjectNode().set(prefix.isEmpty() ? "it" : prefix, node);
      prefix = "";
    }

// Path: RosettaCore/src/main/java/com/hubspot/rosetta/RosettaBinder.java
// public enum RosettaBinder {
//   INSTANCE;
// 
//   public interface Callback {
//     void bind(String key, Object value);
//   }
// 
//   public void bind(String prefix, JsonNode node, Callback callback) {
//     for (Iterator<Entry<String, JsonNode>> iterator = node.fields(); iterator.hasNext(); ) {
//       Entry<String, JsonNode> field = iterator.next();
//       String key = prefix.isEmpty() ? field.getKey() : prefix + "." + field.getKey();
//       JsonNode value = field.getValue();
// 
//       if (value.isObject()) {
//         bind(key, value, callback);
//       } else if (value.isArray()) {
//         List<Object> elements = new ArrayList<>();
//         for (JsonNode element : value) {
//           elements.add(unwrapJsonValue(element));
//         }
// 
//         callback.bind(key, elements);
//       } else {
//         callback.bind(key, unwrapJsonValue(value));
//       }
//     }
//   }
// 
//   private Object unwrapJsonValue(JsonNode node) {
//     if (node.isNull()) {
//       return null;
//     } else if (node.isBoolean()) {
//       return node.booleanValue();
//     } else if (node.isBinary()) {
//       return ((BinaryNode) node).binaryValue();
//     } else if (node.isNumber()) {
//       return node.numberValue();
//     } else {
//       return node.asText();
//     }
//   }
// }


// Path: RosettaJdbi/src/main/java/com/hubspot/rosetta/jdbi/RosettaJdbiBinder.java
import com.fasterxml.jackson.databind.ObjectMapper;
import com.hubspot.rosetta.RosettaBinder;
import com.hubspot.rosetta.RosettaBinder.Callback;
import org.skife.jdbi.v2.SQLStatement;
import com.fasterxml.jackson.databind.JsonNode;
import org.skife.jdbi.v2.sqlobject.Binder;

package com.hubspot.rosetta.jdbi;



public enum RosettaJdbiBinder implements Binder<BindWithRosetta, Object> {
  INSTANCE;

  @Override
  public void bind(final SQLStatement<?> q, BindWithRosetta bind, Object arg) {
    ObjectMapper objectMapper = RosettaObjectMapperOverride.resolve(q.getContext());

    JsonNode node = objectMapper.valueToTree(arg);
    String prefix = bind.value();

    if (node.isValueNode() || node.isArray()) {
      node = objectMapper.createObjectNode().set(prefix.isEmpty() ? "it" : prefix, node);
      prefix = "";
    }

    RosettaBinder.INSTANCE.bind(prefix, node, new Callback() {