/**
   * Get the Java runtime class for the specified message type QName.
   *
   * @param name The message type {@link javax.xml.namespace.QName}.
   * @return The Java runtime class for the specified message type QName, otherwise null.
   */
  public static Class<?> toJavaMessageType(QName name) {
    if (!isJavaMessageType(name)) {
      throw new RuntimeException(
          "Invalid call.  Not a Java message type.  Use isJavaMessageType before calling this method.");
    }

    String className = name.getLocalPart().substring(JAVA_TYPE_PREFIX.length());
    if (!PRIMITIVES.contains(className) && className.contains("[]")) {
      className = className.substring(0, className.length() - 2);
      return Array.newInstance(Classes.forName(className), 0).getClass();
    }
    return Classes.forName(className);
  }
  private static Class getObjectFactory(Class<?> type) {
    if (type.getAnnotation(XmlType.class) != null) {
      // Get the ObjectFactory, if it exists...
      String objectFactoryName = type.getPackage().getName() + "." + "ObjectFactory";

      return Classes.forName(objectFactoryName, JAXBTransformerFactory.class);
    }

    return null;
  }
 /**
  * Will create a new ContextMapper based on the specifications of the passed in
  * ContextMapperModel, or if a class it not specified, will apply the rest of the model properties
  * on the default/fallback implementation.
  *
  * @param model contains the config details
  * @return the new ContextMapper instance
  */
 @SuppressWarnings("unchecked")
 public final ContextMapper<D> newContextMapper(ContextMapperModel model) {
   ContextMapper<D> contextMapper = null;
   ContextMapperFactory<D> contextMapperFactory =
       ContextMapperFactory.getContextMapperFactory(getBindingDataClass());
   if (model != null) {
     contextMapper =
         contextMapperFactory.newContextMapper(
             (Class<ContextMapper<D>>) Classes.forName(model.getClazz()));
     contextMapper.setModel(model);
     if (contextMapper instanceof RegexContextMapper) {
       RegexContextMapper<D> regexContextMapper = (RegexContextMapper<D>) contextMapper;
       regexContextMapper.setIncludes(model.getIncludes());
       regexContextMapper.setExcludes(model.getExcludes());
       regexContextMapper.setIncludeNamespaces(model.getIncludeNamespaces());
       regexContextMapper.setExcludeNamespaces(model.getExcludeNamespaces());
     }
   } else {
     contextMapper = contextMapperFactory.newContextMapperDefault();
   }
   return contextMapper;
 }
 /**
  * Overridable method for resolving a class which allows environments like OSGi to customize
  * resolution.
  */
 protected Class<?> getClass(String className) {
   return Classes.forName(className, TransformerUtil.class);
 }