Generate a single module that is produced by accumulating and overriding
each module with the next.

<pre>
{@code
Guice.createInjector(ModuleUtils.combineAndOverride(moduleA, moduleAOverrides, moduleB));
}
</pre>

@param modules
@return
2198
public static Module combineAndOverride(List<? extends Module> modules) {
        Iterator<? extends Module> iter = modules.iterator();
        Module current = Modules.EMPTY_MODULE;
        if (iter.hasNext()) {
            current = iter.next();
            if (iter.hasNext()) {
                current = Modules.override(current).with(iter.next());
            }
        }
        
        return current;
    }
963899
protected void addModulesToJetty(HandlerCollection handlers) throws Exception {
    	/* *************
         * Manager API
         * ************* */
        ServletContextHandler apiManServer = new ServletContextHandler(ServletContextHandler.SESSIONS);
        addSecurityHandler(apiManServer);
        apiManServer.setContextPath("/apiman");
        apiManServer.addEventListener(new Listener());
        apiManServer.addEventListener(new BeanManagerResourceBindingListener());
        apiManServer.addEventListener(new ResteasyBootstrap());
        apiManServer.addFilter(LocaleFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST));
        apiManServer.addFilter(ApimanCorsFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST));
        apiManServer.addFilter(DisableCachingFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST));
        addAuthFilter(apiManServer);
        apiManServer.addFilter(DefaultSecurityContextFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST));
        apiManServer.addFilter(RootResourceFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST));
        apiManServer.addFilter(ManagerApiMicroServiceTxWatchdogFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST));
        ServletHolder resteasyServlet = new ServletHolder(new HttpServletDispatcher());
        resteasyServlet.setInitParameter("javax.ws.rs.Application", ManagerApiMicroServiceApplication.class.getName());
        apiManServer.addServlet(resteasyServlet, "/*");

        apiManServer.setInitParameter("resteasy.injector.factory", "org.jboss.resteasy.cdi.CdiInjectorFactory");
        apiManServer.setInitParameter("resteasy.scan", "true");
        apiManServer.setInitParameter("resteasy.servlet.mapping.prefix", "");

        handlers.addHandler(apiManServer);

        /* ********** *
         * Manager UI *
         * ********** */
        ResourceHandler apimanUiServer = new ResourceHandler() {
            /**
             * @see org.eclipse.jetty.server.handler.ResourceHandler#getResource(java.lang.String)
             */
            @Override
            public Resource getResource(String path) {
                Resource resource = null;

                if (path == null || path.equals("/") || path.equals("/index.html")) {
                    path = "/index.html";
                }
                if (path.startsWith("/apimanui/api-manager") || path.equals("/apimanui") || path.equals("/apimanui/")) {
                    path = "/apimanui/index.html";
                }
                if (path.equals("/apimanui/apiman/config.js")) {
                    resource = getConfigResource(path);
                }
                if (path.equals("/apimanui/apiman/translations.js")) {
                    resource = getTranslationsResource(path);
                }

                if (resource == null) {
                    URL url = getClass().getResource(path);
                    if (url != null) {
                        resource = new ApimanResource(url);
                    }
                }

                return resource;
            }
        };
        apimanUiServer.setResourceBase("/apimanui/");
        apimanUiServer.setWelcomeFiles(new String[] { "index.html" });
        handlers.addHandler(apimanUiServer);
    }
86613
public static Set<Dependency> getAllDependencies(final Module module) {
        final Set<Dependency> dependencies = new HashSet<Dependency>();
        dependencies.addAll(module.getDependencies());

        for(final Module submodule: module.getSubmodules()){
            dependencies.addAll(getAllDependencies(submodule));
        }

        return dependencies;
    }
266903
@Override
    protected Stream<Module> buildGuiceModules() {
        return Stream.concat(Stream.concat(
                    super.buildGuiceModules(),
                    sqlConfiguration.buildGuiceModules()),
                Stream.of(
                        new OntopMappingSQLModule(this),
                        new OntopMappingPostModule(getSettings())));
    }
804080
@Override
    public T addAsModules(final String... resourceNames) throws IllegalArgumentException {
        // Precondition checks
        Validate.notNull(resourceNames, "resourceNames must be specified");

        // Add each
        for (final String resourceName : resourceNames) {
            this.addAsModule(resourceName);
        }

        // Return
        return this.covarientReturn();
    }
565696
public static SimpleModule getModule(final ObjectMapper mapper) {
        SimpleModule module = new SimpleModule();
        module.setDeserializerModifier(new BeanDeserializerModifier() {
            @Override
            public JsonDeserializer<?> modifyDeserializer(DeserializationConfig config, BeanDescription beanDesc, JsonDeserializer<?> deserializer) {
                for (Class<?> c : TypeToken.of(beanDesc.getBeanClass()).getTypes().classes().rawTypes()) {
                    Field[] fields = c.getDeclaredFields();
                    for (Field field : fields) {
                        if ("additionalProperties".equalsIgnoreCase(field.getName())) {
                            JsonProperty property = field.getAnnotation(JsonProperty.class);
                            if (property != null && property.value().isEmpty()) {
                                return new AdditionalPropertiesDeserializer(beanDesc.getBeanClass(), deserializer, mapper);
                            }
                        }
                    }
                }
                return deserializer;
            }
        });
        return module;
    }
975347
public static Module createModule(final String name,final String version){
        final Module module = new Module();

        module.setName(name);
        module.setVersion(version);
        module.setPromoted(false);

        return module;

    }
1322143
public static List<DbModule> getAllSubmodules(final DbModule module) {
        final List<DbModule> submodules = new ArrayList<DbModule>();
        submodules.addAll(module.getSubmodules());

        for(final DbModule submodule: module.getSubmodules()){
            submodules.addAll(getAllSubmodules(submodule));
        }

        return submodules;
    }
942038
public static SimpleModule getModule(final ObjectMapper mapper) {
        SimpleModule module = new SimpleModule();
        module.setDeserializerModifier(new BeanDeserializerModifier() {
            @Override
            public JsonDeserializer<?> modifyDeserializer(DeserializationConfig config, BeanDescription beanDesc, JsonDeserializer<?> deserializer) {
                if (BeanDeserializer.class.isAssignableFrom(deserializer.getClass())) {
                    // Apply flattening deserializer on all POJO types.
                    return new FlatteningDeserializer(beanDesc.getBeanClass(), deserializer, mapper);
                } else {
                    return deserializer;
                }
            }
        });
        return module;
    }
431501
public TupleGeneratorBuilder combiners( TupleCombiner... combiners)
    {
    for( TupleCombiner combiner : combiners)
      {
      tupleGenerator_.addCombiner( combiner);
      }
    return this;
    }
1309945
function createModule(module) {
        var moduleInstance,
            moduleId;

        if (typeof module === 'function') {
            try {
                moduleInstance = module();
            } catch (ex) {
                if (module.getId) {
                    moduleId = module.getId();
                } else {
                    moduleId = module.name;
                }

                error('Failed to create an instance of module "' + moduleId + '".',
                      'Application will continue running without the module. ' +
                      'See following exception stack for more details.',
                      ex.stack);
            }
        } else {
            moduleInstance = module;
        }

        addOne(moduleInstances, moduleInstance);

        return moduleInstance;
    }
773261
public java.util.List<? extends com.google.javascript.jscomp.FunctionInformationMap.ModuleOrBuilder> 
      getModuleOrBuilderList() {
    return module_;
  }
819795
Map<String, JSModule> getModulesByName() {
    Map<String, JSModule> result = new HashMap<>();
    for (JSModule m : modules) {
      result.put(m.getName(), m);
    }
    return result;
  }
1326325
public Injector createInjector() {
        for (final TypeLiteral<?> typeLiteral : _inheritedTypeLiterals) {
            final Key<?> key = Key.get(typeLiteral);
            final Binding<?> binding = _parentInjector.getExistingBinding(key);
            if (binding != null) {
                if (!_adHocModule.hasBindingFor(typeLiteral)) {
                    // Bind entry if not already bound in adhoc module!!!
                    _adHocModule.bind(typeLiteral, binding.getProvider());
                }
            }
        }

        final Module module = Modules.override(_parentModule).with(_adHocModule);
        return Guice.createInjector(module);
    }
112093
static ObjectGraph createWith(Loader loader, Object... modules) {
    return DaggerObjectGraph.makeGraph(null, loader, modules);
  }
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();
  }
304499
public static SimpleModule getModule(final ObjectMapper mapper) {
        SimpleModule module = new SimpleModule();
        module.setSerializerModifier(new BeanSerializerModifier() {
            @Override
            public JsonSerializer<?> modifySerializer(SerializationConfig config, BeanDescription beanDesc, JsonSerializer<?> serializer) {
                for (Class<?> c : TypeUtil.getAllClasses(beanDesc.getBeanClass())) {
                    if (c.isAssignableFrom(Object.class)) {
                        continue;
                    }
                    Field[] fields = c.getDeclaredFields();
                    for (Field field : fields) {
                        if ("additionalProperties".equalsIgnoreCase(field.getName())) {
                            JsonProperty property = field.getAnnotation(JsonProperty.class);
                            if (property != null && property.value().isEmpty()) {
                                return new AdditionalPropertiesSerializer(beanDesc.getBeanClass(), serializer, mapper);
                            }
                        }
                    }
                }
                return serializer;
            }
        });
        return module;
    }