content: /* Generated by camel build tools - do NOT edit this file! */
  package org.apache.camel.quarkus.it.support.typeconverter.converters;
  
  import javax.annotation.processing.Generated;
  
  import org.apache.camel.CamelContext;
  import org.apache.camel.CamelContextAware;
  import org.apache.camel.DeferredContextBinding;
  import org.apache.camel.Exchange;
  import org.apache.camel.Ordered;
  import org.apache.camel.TypeConversionException;
  import org.apache.camel.TypeConverterLoaderException;
  import org.apache.camel.TypeConverter;
  import org.apache.camel.spi.TypeConvertible;
  import org.apache.camel.spi.BulkTypeConverters;
  import org.apache.camel.spi.TypeConverterLoader;
  import org.apache.camel.spi.TypeConverterRegistry;
  
  /**
   * Generated by camel build tools - do NOT edit this file!
   */
  @Generated("org.apache.camel.maven.packaging.TypeConverterLoaderGeneratorMojo")
  @SuppressWarnings("unchecked")
  @DeferredContextBinding
  public final class CamelQuarkusIntegrationTestsSupportCustomTypeConverterBulkConverterLoader implements TypeConverterLoader, BulkTypeConverters, CamelContextAware {
  
      private CamelContext camelContext;
  
      public CamelQuarkusIntegrationTestsSupportCustomTypeConverterBulkConverterLoader() {
      }
  
      @Override
      public void setCamelContext(CamelContext camelContext) {
          this.camelContext = camelContext;
      }
  
      @Override
      public CamelContext getCamelContext() {
          return camelContext;
      }
  
      @Override
      public int size() {
          return 2;
      }
  
      @Override
      public void load(TypeConverterRegistry registry) throws TypeConverterLoaderException {
          registry.addBulkTypeConverters(this);
          doRegistration(registry);
      }
  
      @Override
      public <T> T convertTo(Class<?> from, Class<T> to, Exchange exchange, Object value) throws TypeConversionException {
          try {
              Object obj = doConvertTo(from, to, exchange, value);
              return (T) obj;
          } catch (TypeConversionException e) {
              throw e;
          } catch (Exception e) {
              throw new TypeConversionException(value, to, e);
          }
      }
  
      private Object doConvertTo(Class<?> from, Class<?> to, Exchange exchange, Object value) throws Exception {
          if (to == org.apache.camel.quarkus.it.support.typeconverter.pairs.MyBulk1Pair.class) {
              if (value instanceof java.lang.String) {
                  return org.apache.camel.quarkus.it.support.typeconverter.converters.MyBulk1Converter.toMyPair((java.lang.String) value);
              }
          } else if (to == org.apache.camel.quarkus.it.support.typeconverter.pairs.MyBulk2Pair.class) {
              if (value instanceof java.lang.String) {
                  return org.apache.camel.quarkus.it.support.typeconverter.converters.MyBulk2Converter.toMyPair((java.lang.String) value);
              }
          }
          return null;
      }
  
      private void doRegistration(TypeConverterRegistry registry) {
          registry.addConverter(new TypeConvertible<>(java.lang.String.class, org.apache.camel.quarkus.it.support.typeconverter.pairs.MyBulk1Pair.class), this);
          registry.addConverter(new TypeConvertible<>(java.lang.String.class, org.apache.camel.quarkus.it.support.typeconverter.pairs.MyBulk2Pair.class), this);
      }
  
      public TypeConverter lookup(Class<?> to, Class<?> from) {
          if (to == org.apache.camel.quarkus.it.support.typeconverter.pairs.MyBulk1Pair.class) {
              if (from == java.lang.String.class) {
                  return this;
              }
          } else if (to == org.apache.camel.quarkus.it.support.typeconverter.pairs.MyBulk2Pair.class) {
              if (from == java.lang.String.class) {
                  return this;
              }
          }
          return null;
      }
  
  }
  