Write a companion class for {@code type} that implements {@link
ModuleAdapter} to expose its provider methods.
15755
private JavaFile generateModuleAdapter(TypeElement type,
      Map<String, Object> module, List<ExecutableElement> providerMethods) {
    Object[] staticInjections = (Object[]) module.get("staticInjections");
    Object[] injects = (Object[]) module.get("injects");
    Object[] includes = (Object[]) module.get("includes");
    boolean overrides = (Boolean) module.get("overrides");
    boolean complete = (Boolean) module.get("complete");
    boolean library = (Boolean) module.get("library");

    List<Object> duplicateInjects = extractDuplicates(injects);
    if (!duplicateInjects.isEmpty()) {
      error("'injects' list contains duplicate entries: " + duplicateInjects, type);
    }
    List<Object> duplicateIncludes = extractDuplicates(includes);
    if (!duplicateIncludes.isEmpty()) {
      error("'includes' list contains duplicate entries: " + duplicateIncludes, type);
    }

    ClassName moduleClassName = ClassName.get(type);
    ClassName adapterClassName = Util.adapterName(moduleClassName, MODULE_ADAPTER_SUFFIX);

    TypeSpec.Builder adapterBuilder = TypeSpec.classBuilder(adapterClassName.simpleName())
        .addOriginatingElement(type)
        .addJavadoc(AdapterJavadocs.MODULE_TYPE, Provides.class)
        .superclass(ParameterizedTypeName.get(ClassName.get(ModuleAdapter.class), moduleClassName))
        .addModifiers(PUBLIC, FINAL);

    adapterBuilder.addField(FieldSpec.builder(String[].class, "INJECTS")
        .addModifiers(PRIVATE, STATIC, FINAL)
        .initializer("$L", injectsInitializer(injects))
        .build());
    adapterBuilder.addField(FieldSpec.builder(ARRAY_OF_CLASS, "STATIC_INJECTIONS")
        .addModifiers(PRIVATE, STATIC, FINAL)
        .initializer("$L", staticInjectionsInitializer(staticInjections))
        .build());
    adapterBuilder.addField(FieldSpec.builder(ARRAY_OF_CLASS, "INCLUDES")
        .addModifiers(PRIVATE, STATIC, FINAL)
        .initializer("$L", includesInitializer(type, includes))
        .build());
    adapterBuilder.addMethod(MethodSpec.constructorBuilder()
        .addModifiers(PUBLIC)
        .addStatement("super($T.class, INJECTS, STATIC_INJECTIONS, $L /*overrides*/, "
                + "INCLUDES, $L /*complete*/, $L /*library*/)",
            type.asType(), overrides, complete, library)
        .build());

    ExecutableElement noArgsConstructor = getNoArgsConstructor(type);
    if (noArgsConstructor != null && isCallableConstructor(noArgsConstructor)) {
      adapterBuilder.addMethod(MethodSpec.methodBuilder("newModule")
          .addAnnotation(Override.class)
          .addModifiers(PUBLIC)
          .returns(moduleClassName)
          .addStatement("return new $T()", type.asType())
          .build());
    }

    // Caches.
    Map<ExecutableElement, ClassName> methodToClassName
        = new LinkedHashMap<ExecutableElement, ClassName>();
    Map<String, AtomicInteger> methodNameToNextId = new LinkedHashMap<String, AtomicInteger>();

    if (!providerMethods.isEmpty()) {
      MethodSpec.Builder getBindings = MethodSpec.methodBuilder("getBindings")
          .addJavadoc(AdapterJavadocs.GET_DEPENDENCIES_METHOD)
          .addAnnotation(Override.class)
          .addModifiers(PUBLIC)
          .addParameter(BindingsGroup.class, "bindings")
          .addParameter(moduleClassName, "module");

      for (ExecutableElement providerMethod : providerMethods) {
        Provides provides = providerMethod.getAnnotation(Provides.class);
        switch (provides.type()) {
          case UNIQUE: {
            getBindings.addStatement("bindings.contributeProvidesBinding($S, new $T(module))",
                GeneratorKeys.get(providerMethod),
                bindingClassName(adapterClassName, providerMethod, methodToClassName,
                    methodNameToNextId));
            break;
          }
          case SET: {
            getBindings.addStatement("$T.add(bindings, $S, new $T(module))",
                SetBinding.class,
                GeneratorKeys.getSetKey(providerMethod),
                bindingClassName(adapterClassName, providerMethod, methodToClassName,
                    methodNameToNextId));
            break;
          }
          case SET_VALUES: {
            getBindings.addStatement("$T.add(bindings, $S, new $T(module))",
                SetBinding.class,
                GeneratorKeys.get(providerMethod),
                bindingClassName(adapterClassName, providerMethod, methodToClassName,
                    methodNameToNextId));
            break;
          }
          default:
            throw new AssertionError("Unknown @Provides type " + provides.type());
        }
      }
      adapterBuilder.addMethod(getBindings.build());
    }

    for (ExecutableElement providerMethod : providerMethods) {
      adapterBuilder.addType(generateProvidesAdapter(moduleClassName, adapterClassName,
          providerMethod, methodToClassName, methodNameToNextId, library));
    }

    return JavaFile.builder(adapterClassName.packageName(), adapterBuilder.build())
        .addFileComment(AdapterJavadocs.GENERATED_BY_DAGGER)
        .build();
  }
713775
public <T> TypeAdapter<T> getAdapter(Class<T> type) {
    return getAdapter(TypeToken.get(type));
  }
1335412
@SuppressWarnings("unchecked")
  public <T> TypeAdapter<T> getAdapter(TypeToken<T> type) {
    TypeAdapter<?> cached = typeTokenCache.get(type == null ? NULL_KEY_SURROGATE : type);
    if (cached != null) {
      return (TypeAdapter<T>) cached;
    }

    Map<TypeToken<?>, FutureTypeAdapter<?>> threadCalls = calls.get();
    boolean requiresThreadLocalCleanup = false;
    if (threadCalls == null) {
      threadCalls = new HashMap<TypeToken<?>, FutureTypeAdapter<?>>();
      calls.set(threadCalls);
      requiresThreadLocalCleanup = true;
    }

    // the key and value type parameters always agree
    FutureTypeAdapter<T> ongoingCall = (FutureTypeAdapter<T>) threadCalls.get(type);
    if (ongoingCall != null) {
      return ongoingCall;
    }

    try {
      FutureTypeAdapter<T> call = new FutureTypeAdapter<T>();
      threadCalls.put(type, call);

      for (TypeAdapterFactory factory : factories) {
        TypeAdapter<T> candidate = factory.create(this, type);
        if (candidate != null) {
          call.setDelegate(candidate);
          typeTokenCache.put(type, candidate);
          return candidate;
        }
      }
      throw new IllegalArgumentException("GSON (" + GsonBuildConfig.VERSION + ") cannot handle " + type);
    } finally {
      threadCalls.remove(type);

      if (requiresThreadLocalCleanup) {
        calls.remove();
      }
    }
  }
771864
public JsonConverterBuilder registerJsonTypeAdapter(JsonTypeAdapter adapter) {
        Validate.argumentIsNotNull(adapter);
        adapter.getValueTypes().forEach( c -> registerJsonTypeAdapterForType((Class)c, adapter));
        return this;
    }
662631
public <T> Provider<T> getCurrentInstanceProvider(Class<T> type) {
		return getCurrentInstanceProvider(Key.get(type));
	}
477867
public static void addSupport(AbstractModule module) {
        module.bindInstance(SQLCodegenModule.ENTITYPATH_TYPE, RelationalPathSpatial.class);
        registerTypes(module.get(Configuration.class));
        registerTypes(module.get(TypeMappings.class));
        addImports(module);
    }
449307
public static <E, M extends BinderMapper<E>> M mapperFor(ParameterizedType type) throws NoSuchMapperException {
		@SuppressWarnings("unchecked")
		M mapper = AbstractContext.getMapper((Class<E>) type.getActualTypeArguments()[0]);
		if (mapper == null) {
			throw new NoSuchMapperException(type.getRawType());
		} else {
			return mapper;
		}
	}
479765
@Override
    public Converter getConverter(Class<?> valueType) {
        ConverterProvider provider = findProvider(valueType);
        if (provider == null) {
            return null;
        }
        return provider.createConverter(valueType);
    }
1305360
public static <TYPE> Provider<TYPE> of(final Class<TYPE> clazz,
            @Nullable final Map<String, String> overrides)
    {
        return of(null, clazz, overrides);
    }
196650
function getAdapter(serviceInfo, resource, moduleStack) {
        var adapterName = serviceInfo.adapterName;

        // if adapter name is 'service' and there is a default, switch to the default
        if (adapterName === 'service' && resource.adapters[this.injector.container]) {
            adapterName = serviceInfo.adapterName = resource.adapters[this.injector.container];
            serviceInfo.adapterImpl = this.injector.adapterMap[adapterName];
            serviceInfo.serviceName = utils.getCamelCase(serviceInfo.resourceName + '.' +
                serviceInfo.adapterName + '.service');
        }

        // if that doesn't work, we will assume the adapter is in the current codebase, so go get it
        var overridePath = '/resources/' + serviceInfo.resourceName + '/' + serviceInfo.resourceName + '.' +
            (adapterName === 'service' ? adapterName : adapterName + '.service');
        var adapterPath = '/adapters/' + adapterName + '/' +
            serviceInfo.adapterImpl + '.' + adapterName + '.adapter';

        // if override exists, use that one, else use the lower level adapter
        var Adapter =
            this.loadIfExists(overridePath, moduleStack, null) ||
            this.injector.adapters[serviceInfo.adapterImpl] ||
            this.loadIfExists(adapterPath, moduleStack, null);

        // if still no adapter found, then there is an issue
        if (!Adapter) {
            throw new Error('ServiceFactory could not find adapter ' + adapterName +
            ' paths ' + overridePath + ' and ' + adapterPath);
        }

        return new Adapter(resource);
    }
808434
public static <T> PluggableProviderService<T> getPluginProviderService(
        Class<T> serviceType,
        String serviceName,
        ServiceProviderLoader loader
    )
    {
        for (PluginProviderServices pluginProviderServices : pluginProviderServiceLoader) {
            if (pluginProviderServices.hasServiceFor(serviceType, serviceName)) {
                return pluginProviderServices.getServiceProviderFor(serviceType, serviceName, loader);
            }
        }
        return null;
    }
824081
protected @Nonnull <T> Provider<T> getBeanProvider(@Nullable BeanResolutionContext resolutionContext, @Nonnull Class<T> beanType) {
        return getBeanProvider(resolutionContext, beanType, null);
    }
987328
private Type _writeOutEmpty(BytecodeContext bc) throws TransformerException {
	if (ignoredFirstMember && (scope == Scope.SCOPE_LOCAL || scope == Scope.SCOPE_VAR)) return Types.VOID;

	GeneratorAdapter adapter = bc.getAdapter();
	adapter.loadArg(0);
	Method m;
	Type t = Types.PAGE_CONTEXT;
	if (scope == Scope.SCOPE_ARGUMENTS) {
	    getFactory().TRUE().writeOut(bc, MODE_VALUE);
	    m = TypeScope.METHOD_ARGUMENT_BIND;
	}
	else if (scope == Scope.SCOPE_LOCAL) {
	    t = Types.PAGE_CONTEXT;
	    getFactory().TRUE().writeOut(bc, MODE_VALUE);
	    m = TypeScope.METHOD_LOCAL_BIND;
	}
	else if (scope == Scope.SCOPE_VAR) {
	    t = Types.PAGE_CONTEXT;
	    getFactory().TRUE().writeOut(bc, MODE_VALUE);
	    m = TypeScope.METHOD_VAR_BIND;
	}
	else m = TypeScope.METHODS[scope];

	TypeScope.invokeScope(adapter, m, t);

	return m.getReturnType();
    }
1197741
static CodeBlock bindingTypeDocs(
      TypeName type, boolean abstrakt, boolean members, boolean dependent) {
    CodeBlock.Builder result = CodeBlock.builder()
        .add("A {@code Binding<$T>} implementation which satisfies\n", type)
        .add("Dagger's infrastructure requirements including:\n");
    if (dependent) {
      result.add("\n")
          .add("Owning the dependency links between {@code $T} and its\n", type)
          .add("dependencies.\n");
    }
    if (!abstrakt) {
      result.add("\n")
          .add("Being a {@code Provider<$T>} and handling creation and\n", type)
          .add("preparation of object instances.\n");
    }
    if (members) {
      result.add("\n")
          .add("Being a {@code MembersInjector<$T>} and handling injection\n", type)
          .add("of annotated fields.\n");
    }
    return result.build();
  }
1150805
public <C> C mapTo(Class<C> type) {
    DataFormatMapper mapper = dataFormat.getMapper();
    return mapper.mapInternalToJava(jsonNode, type);
  }
634312
@SuppressWarnings("unchecked")
	public <Input,Output> Output adapt(Input input, Class<Output> outputType) throws Exception {
		Class<?> inputType = input.getClass();
		Adapter a = findAdapter(input, inputType, outputType);
		if (a == null) return null;
		return (Output)a.adapt(input);
	}
418114
private List<ParameterConverter> methodReturningConverters(final Class<?> type) {
        final List<ParameterConverter> converters = new ArrayList<>();
        for (final Method method : type.getMethods()) {
            if (method.isAnnotationPresent(AsParameterConverter.class)) {
                converters.add(new MethodReturningConverter(method, type, this));
            }
        }
        return converters;
    }