package io.github.jklingsporn.vertx.jooq.shared;

import java.lang.ClassCastException;

/**
 * A custom exception type that is thrown from JSON converters, instead of {@link java.lang.ClassCastException}
 * when the expected type is different than the provided type.
 * @author guss77
 */
public class UnexpectedJsonValueType extends ClassCastException {
  private static final long serialVersionUID = 8727637165178779604L;
  
  public UnexpectedJsonValueType(String fieldName, String fieldType, ClassCastException cause) {
    super("Invalid JSON type provided for field '" + fieldName + "', expecting: " +
        fieldType.replaceAll("\\w+\\.","").toLowerCase()); // trim field type to something JSON lovers would recognize
  }
  
}

@@ -604,127 +604,376 @@
  %22 +
-%0A        fieldType.replaceAll(%22%5C%5Cw+%5C%5C.%22,%22%22).toLowerCase()); // trim field type to something JSON lovers would recognize
+ jsonifyType(fieldType));%0A  %7D%0A  %0A  /**%0A   * Trim field type to something JSON lovers would recognize.%0A   * @param type The Java type%0A   * @return a not exactly JSON type, but close%0A   */%0A  private static String jsonifyType(String type) %7B%0A    return type%0A      .replaceAll(%22%5C%5Cw+%5C%5C.%22,%22%22) // remove package%0A      .replace(%22Json%22,%22%22); // handle Vert.x's Json(Object%7CArray)
 %0A  %7D

move jsonifying to its a method so we can do more stuff