/*
(non-Javadoc)

@see
net.jawr.web.resource.bundle.mappings.BundlePathMappingBuilder#build(java
.util.List)
183748
@Override
	public BundlePathMapping build(List<String> strPathMappings) {

		BundlePathMapping bundlePathMapping = new BundlePathMapping(bundle);
		for (JoinableResourceBundle child : ((CompositeResourceBundle) bundle).getChildBundles()) {
			if (!child.getInclusionPattern().isIncludeOnlyOnDebug()) {
				bundlePathMapping.getItemPathList().addAll(child.getItemPathList());
				addFilePathMapping(bundlePathMapping, child.getItemPathList());
			}

			if (!child.getInclusionPattern().isExcludeOnDebug()) {
				bundlePathMapping.getItemDebugPathList().addAll(child.getItemDebugPathList());
				addFilePathMapping(bundlePathMapping, child.getItemDebugPathList());
			}
			bundlePathMapping.getLicensesPathList().addAll(child.getLicensesPathList());
			addFilePathMapping(bundlePathMapping, child.getLicensesPathList());
		}
		return bundlePathMapping;
	}
458090
protected <T> JsonObjectBase buildListSuccess(List<?> value, int totalCount) {

        return JsonObjectUtils.buildListSuccess(value, totalCount, null);
    }
112146
public String   build(ServiceInstance<?> serviceInstance)
    {
        return build(serviceInstance, Maps.<String, Object>newHashMap());
    }
44528
public static <S> MultiAction<S> buildChain(final List<? extends Action<S>> actions) {
	return new Builder<S>().addPerform(actions).build();
    }
1128671
private ResultMapping buildResultMapping(Configuration configuration, String property, String column, Class<?> javaType, List<ResultFlag> flags) {
    ResultMapping.Builder builder = new ResultMapping.Builder(configuration, property, column, javaType);
    builder.flags(flags == null ? new ArrayList<ResultFlag>() : flags);
    builder.composites(new ArrayList<ResultMapping>());
    builder.notNullColumns(new HashSet<String>());
    return builder.build();
  }
520641
private String buildPath(List<String> path) {
        StringBuilder sb = new StringBuilder();

        for (int i = 0; i < path.size(); i++) {
            if (i > 0) {
                sb.append('.');
            }

            sb.append(path.get(i));
        }

        return sb.toString();
    }
26948
@Override
	public ModuleBuild build(String mid, IResource resource, HttpServletRequest request, List<ICacheKeyGenerator> inKeyGens) throws Exception {

		// Manage life span of thread locals used by this module builder
		if (isFeatureDependent) {
			threadLocalRequest.set(request);
			threadLocalDependentFeatures.set(null);
		}
		try {
			return super.build(mid, resource, request, inKeyGens);
		}	finally {
			if (isFeatureDependent) {
				threadLocalRequest.remove();
				threadLocalDependentFeatures.remove();
			}
		}
	}
58188
public static <E> List<E> buildList(Iterable<E> iterable) {
        return StreamSupport.stream(iterable.spliterator(), false)
                .collect(toList());
    }
152018
protected function buildList()
    {
        if ($this->list) {
            return;
        }

        $this->list = $this->getListBuilder()->getBaseList();

        $mapper = new ListMapper($this->getListBuilder(), $this->list, $this);

        if (\count($this->getBatchActions()) > 0 && $this->hasRequest() && !$this->getRequest()->isXmlHttpRequest()) {
            $fieldDescription = $this->getModelManager()->getNewFieldDescriptionInstance(
                $this->getClass(),
                'batch',
                [
                    'label' => 'batch',
                    'code' => '_batch',
                    'sortable' => false,
                    'virtual_field' => true,
                ]
            );

            $fieldDescription->setAdmin($this);
            // NEXT_MAJOR: Remove this line and use commented line below it instead
            $fieldDescription->setTemplate($this->getTemplate('batch'));
            // $fieldDescription->setTemplate($this->getTemplateRegistry()->getTemplate('batch'));

            $mapper->add($fieldDescription, 'batch');
        }

        $this->configureListFields($mapper);

        foreach ($this->getExtensions() as $extension) {
            $extension->configureListFields($mapper);
        }

        if ($this->hasRequest() && $this->getRequest()->isXmlHttpRequest()) {
            $fieldDescription = $this->getModelManager()->getNewFieldDescriptionInstance(
                $this->getClass(),
                'select',
                [
                    'label' => false,
                    'code' => '_select',
                    'sortable' => false,
                    'virtual_field' => false,
                ]
            );

            $fieldDescription->setAdmin($this);
            // NEXT_MAJOR: Remove this line and use commented line below it instead
            $fieldDescription->setTemplate($this->getTemplate('select'));
            // $fieldDescription->setTemplate($this->getTemplateRegistry()->getTemplate('select'));

            $mapper->add($fieldDescription, 'select');
        }
    }
253008
@Override
  protected void buildClassPath(ArrayList<String> pathList)
  {
    if (! _classDir.getScheme().equals("file"))
      return;

    try {
      if (! _classDir.isDirectory() && _sourceDir.isDirectory()) {
        try {
          _classDir.mkdirs();
        } catch (IOException e) {
        }
      }

      if (_classDir.isDirectory()) {
        String path = _classDir.getNativePath();

        if (! pathList.contains(path))
          pathList.add(path);
      }
    
      if (! _classDir.equals(_sourceDir)) {
        String path = _sourceDir.getNativePath();

        if (! pathList.contains(path))
          pathList.add(path);
      }
    } catch (java.security.AccessControlException e) {
      log.log(Level.WARNING, e.toString(), e);
    }
  }
373507
public int build(TreeMap<String, V> keyValueMap)
    {
        assert keyValueMap != null;
        Set<Map.Entry<String, V>> entrySet = keyValueMap.entrySet();
        return build(entrySet);
    }
696180
public void build(Elements elementUtils, Filer filer, SQLiteDatabaseSchema schema) throws Exception {
		uriSet.clear();

		String dataSourceName = schema.getName();
		String dataSourceNameClazz = BindDataSourceBuilder.PREFIX + dataSourceName;
		String contentProviderName = PREFIX + dataSourceName.replace(BindDataSourceBuilder.SUFFIX, "") + SUFFIX;

		PackageElement pkg = elementUtils.getPackageOf(schema.getElement());
		String packageName = pkg.isUnnamed() ? null : pkg.getQualifiedName().toString();

		AnnotationProcessorUtilis.infoOnGeneratedClasses(BindContentProvider.class, packageName, contentProviderName);
		classBuilder = TypeSpec.classBuilder(contentProviderName).addModifiers(Modifier.PUBLIC).superclass(ContentProvider.class);

		classBuilder.addJavadoc("<p>This is the content provider generated for {@link $L}</p>\n\n", dataSourceName);

		classBuilder.addJavadoc("<h2>Content provider authority:</h2>\n");
		classBuilder.addJavadoc("<pre>$L</pre>\n\n", schema.contentProvider.authority);

		generateOnCreate(dataSourceNameClazz);
		generateOnShutdown(dataSourceNameClazz);

		// define static fields
		classBuilder.addField(FieldSpec.builder(String.class, "URI", Modifier.STATIC, Modifier.PUBLIC, Modifier.FINAL).initializer("$S", schema.contentProviderUri())
				.addJavadoc("<p>content provider's URI.</p>\n<pre>$L</pre>\n", schema.contentProviderUri()).build());

		// instance
		classBuilder.addField(FieldSpec.builder(className(dataSourceNameClazz), "dataSource", Modifier.PRIVATE, Modifier.STATIC).addJavadoc("<p>datasource singleton</p>\n").build());
		classBuilder.addField(FieldSpec.builder(String.class, "AUTHORITY", Modifier.PUBLIC, Modifier.STATIC, Modifier.FINAL).addJavadoc("<p>Content provider authority</p>\n")
				.initializer("$S", schema.contentProvider.authority).build());
		classBuilder.addField(FieldSpec.builder(UriMatcher.class, "sURIMatcher", Modifier.PRIVATE, Modifier.STATIC, Modifier.FINAL).addJavadoc("<p>URI matcher</p>\n")
				.initializer("new $T($T.NO_MATCH)", UriMatcher.class, UriMatcher.class).build());

		Builder staticBuilder = CodeBlock.builder();
		Converter<String, String> daoConstantConverter = CaseFormat.UPPER_CAMEL.converterTo(CaseFormat.UPPER_UNDERSCORE);

		List<FieldSpec> listFieldUri = new ArrayList<>();
		List<FieldSpec> listFieldString = new ArrayList<>();
		List<FieldSpec> listFieldIndex = new ArrayList<>();
		List<FieldSpec> listFieldAlias = new ArrayList<>();

		for (SQLiteDaoDefinition daoDefinition : schema.getCollection()) {
			String pathConstantName = "PATH_" + daoConstantConverter.convert(daoDefinition.getEntitySimplyClassName());

			if (!daoDefinition.contentProviderEnabled)
				continue;

			// define content provider paths
			for (SQLiteModelMethod daoMethod : daoDefinition.getCollection()) {
				if (!daoMethod.contentProviderEntryPathEnabled)
					continue;

				ContentEntry entry = uriSet.get(daoMethod.contentProviderEntryPathTemplate);
				if (entry == null) {
					entry = new ContentEntry(daoMethod.contentProviderEntryPath);
					uriSet.put(daoMethod.contentProviderEntryPathTemplate, entry);

					entry.path = daoMethod.contentProviderEntryPath;
					entry.uriTemplate = daoMethod.contentProviderEntryPathTemplate;

					// we finish later
					entry.pathCostant = pathConstantName;
					entry.pathIndex = pathConstantName;
				}

				switch (daoMethod.jql.operationType) {
				case INSERT:
					AssertKripton.fail(entry.insert != null, String.format("In DAO '%s', there are more than one %s statement associated to content provider path '%s'",
							daoDefinition.getName().toString(), daoMethod.jql.operationType, entry.path));
					entry.insert = daoMethod;
					break;
				case UPDATE:
					AssertKripton.fail(entry.update != null, String.format("In DAO '%s', there are more than one %s statement associated to content provider path '%s'",
							daoDefinition.getName().toString(), daoMethod.jql.operationType, entry.path));
					entry.update = daoMethod;
					break;
				case SELECT:
					AssertKripton.fail(entry.select != null, String.format("In DAO '%s', there are more than one %s statement associated to content provider path '%s'",
							daoDefinition.getName().toString(), daoMethod.jql.operationType, entry.path));
					entry.select = daoMethod;
					break;
				case DELETE:
					AssertKripton.fail(entry.delete != null, String.format("In DAO '%s', there are more than one %s statement associated to content provider path '%s'",
							daoDefinition.getName().toString(), daoMethod.jql.operationType, entry.path));
					entry.delete = daoMethod;
					break;

				}
			}
		}

		// sort uri set by
		List<Pair<String, ContentEntry>> listUriSet = new ArrayList<>();
		Pair<String, ContentEntry> item;
		for (Entry<String, ContentEntry> entry : uriSet.entrySet()) {
			item = new Pair<String, ContentEntry>(entry.getKey(), entry.getValue());
			listUriSet.add(item);
		}

		Comparator<Pair<String, ContentEntry>> c = new Comparator<Pair<String, ContentEntry>>() {

			@Override
			public int compare(Pair<String, ContentEntry> lhs, Pair<String, ContentEntry> rhs) {
				return lhs.value0.compareTo(rhs.value0);
			}

		};
		Collections.sort(listUriSet, c);

		Set<String> alreadyUsedName = new HashSet<String>();
		Converter<String, String> format = CaseFormat.LOWER_CAMEL.converterTo(CaseFormat.UPPER_UNDERSCORE);

		int i = 1;
		for (Pair<String, ContentEntry> entry : listUriSet) {
			// define ordered part of attributes (after sort)
			entry.value1.pathCostant += "_" + i;
			entry.value1.pathIndex += "_" + i + "_INDEX";
			entry.value1.pathValue = i;

			// build class attributes
			listFieldString.add(FieldSpec.builder(String.class, entry.value1.pathCostant, Modifier.STATIC, Modifier.FINAL).initializer(CodeBlock.of("$S", entry.value1.uriTemplate)).build());
			listFieldIndex.add(FieldSpec.builder(Integer.TYPE, entry.value1.pathIndex, Modifier.STATIC, Modifier.FINAL).initializer(CodeBlock.of("$L", entry.value1.pathValue)).build());

			listFieldUri.add(FieldSpec.builder(Uri.class, "URI_" + entry.value1.pathCostant, Modifier.STATIC, Modifier.FINAL, Modifier.PRIVATE).addJavadoc("<p>Uri</p>\n")
					.addJavadoc("<pre>$L/$L</pre>\n", schema.contentProviderUri().replace("*", "[*]"), entry.value1.uriTemplate.replace("*", "[*]"))
					.initializer(CodeBlock.of("Uri.parse(URI+\"/$L\")", entry.value1.uriTemplate)).build());

			generateURIForMethod(schema, listFieldAlias, alreadyUsedName, format, entry, entry.value1.delete);
			generateURIForMethod(schema, listFieldAlias, alreadyUsedName, format, entry, entry.value1.insert);
			generateURIForMethod(schema, listFieldAlias, alreadyUsedName, format, entry, entry.value1.select);
			generateURIForMethod(schema, listFieldAlias, alreadyUsedName, format, entry, entry.value1.update);

			staticBuilder.addStatement("sURIMatcher.addURI(AUTHORITY, $L, $L)", entry.value1.pathCostant, entry.value1.pathIndex);

			i++;
		}

		for (FieldSpec f : listFieldUri) {
			classBuilder.addField(f);
		}

		for (FieldSpec f : listFieldString) {
			classBuilder.addField(f);
		}

		for (FieldSpec f : listFieldIndex) {
			classBuilder.addField(f);
		}

		for (FieldSpec f : listFieldAlias) {
			classBuilder.addField(f);
		}

		classBuilder.addStaticBlock(staticBuilder.build());

		generateQuery(schema);

		generateInsert(schema);

		generateUpdate(schema);

		generateDelete(schema);

		generateGetType(schema);

		classBuilder.addJavadoc("\n\n");
		JavadocUtility.generateJavadocGeneratedBy(classBuilder);

		TypeSpec typeSpec = classBuilder.build();
		JavaWriterHelper.writeJava2File(filer, packageName, typeSpec);
	}
959684
public void build() throws SAXException {
		// reorganize qualifying components by their namespaces to
		// generate the list nicely
		final Map<XSSchema, PerSchemaOutlineAdaptors> perSchema = new LinkedHashMap<>();
		boolean hasComponentInNoNamespace = false;

		for (final OutlineAdaptor oa : this.outlines) {
			final XSComponent sc = oa.schemaComponent;

			if (sc != null && (sc instanceof XSDeclaration)) {
				final XSDeclaration decl = (XSDeclaration) sc;
				if (!decl.isLocal()) { // local components cannot be referenced from outside, so no need to list.
					PerSchemaOutlineAdaptors list = perSchema.get(decl.getOwnerSchema());
					if (list == null) {
						list = new PerSchemaOutlineAdaptors();
						perSchema.put(decl.getOwnerSchema(), list);
					}

					list.add(oa);

					if ("".equals(decl.getTargetNamespace()))
						hasComponentInNoNamespace = true;
				}
			}
		}

		//final File episodeFile = new File(opt.targetDir, this.episodePackageName.replaceAll("\\.", "/") + "/" + this.episodeFileName);
		try (final StringWriter stringWriter = new StringWriter()) {
			final Bindings bindings = TXW.create(Bindings.class, new StreamSerializer(stringWriter));
			if (hasComponentInNoNamespace) // otherwise jaxb binding NS should be the default namespace
				bindings._namespace(Const.JAXB_NSURI, "jaxb");
			else
				bindings._namespace(Const.JAXB_NSURI, "");
			bindings._namespace(Namespaces.KSCS_BINDINGS_NS, "kscs");
			bindings.version("2.1");
			bindings._comment("\n\n" + this.pluginContext.opt.getPrologComment() + "\n  ");

			// generate listing per schema
			for (final Map.Entry<XSSchema, PerSchemaOutlineAdaptors> e : perSchema.entrySet()) {
				final PerSchemaOutlineAdaptors ps = e.getValue();
				final Bindings group = bindings.bindings();
				final String tns = e.getKey().getTargetNamespace();
				if (Namespaces.XML_NS.equals(tns)) {
					group._namespace(tns, "xml");
				} else if (!"".equals(tns)) {
					group._namespace(tns, "tns");
				}

				group.scd("x-schema::" + ("".equals(tns) ? "" : (Namespaces.XML_NS.equals(tns) ? "xml" : "tns")));
				group._attribute("if-exists", "true");

				final SchemaBindings schemaBindings = group.schemaBindings();
				schemaBindings.map(false);
				if (ps.packageNames.size() == 1) {
					final String packageName = ps.packageNames.iterator().next();
					if (packageName != null && packageName.length() > 0) {
						schemaBindings._package().name(packageName);
					}
				}

				for (final OutlineAdaptor oa : ps.outlineAdaptors) {
					final Bindings child = group.bindings();
					oa.buildBindings(child);
				}
				group.commit(true);
			}

			bindings.commit();

			final JTextFile jTextFile = new JTextFile(this.episodeFileName);
			jTextFile.setContents(stringWriter.toString());
			this.pluginContext.codeModel.rootPackage().addResourceFile(jTextFile);
		} catch (final IOException e) {
			this.pluginContext.errorHandler.error(new SAXParseException("Failed to write to " + this.episodeFileName, null, e));
		}
	}
1190623
public <T> List<T> search(QueryBuilder<T> builder) {
    return (List<T>) search(builder.build());
  }
427459
private static void buildComponents(ExecutionContext context) throws ClassNotFoundException, NoSuchMethodException,
            IllegalAccessException, InvocationTargetException, InstantiationException {
        Collection<BeanDef> cDefs = context.getTopologyDef().getComponents();
        if (cDefs != null) {
            for (BeanDef bean : cDefs) {
                Object obj = buildObject(bean, context);
                context.addComponent(bean.getId(), obj);
            }
        }
    }
1080158
public File[] build() {
        MavenStrategyStage maven = Maven.configureResolver()
                .workOffline(offline)
                .resolve(artifactCoordinates);

        return applyTransitivity(maven).asFile();
    }
798091
@SuppressWarnings("rawtypes")
    @Override
    protected IProject[] build(int kind, Map args, IProgressMonitor monitor) throws CoreException {
        monitor.subTask("Running SpotBugs...");
        switch (kind) {
        case IncrementalProjectBuilder.FULL_BUILD: {
            FindBugs2Eclipse.cleanClassClache(getProject());
            if (FindbugsPlugin.getUserPreferences(getProject()).isRunAtFullBuild()) {
                if (DEBUG) {
                    System.out.println("FULL BUILD");
                }
                doBuild(args, monitor, kind);
            } else {
                // TODO probably worth to cleanup?
                // MarkerUtil.removeMarkers(getProject());
            }
            break;
        }
        case IncrementalProjectBuilder.INCREMENTAL_BUILD: {
            if (DEBUG) {
                System.out.println("INCREMENTAL BUILD");
            }
            doBuild(args, monitor, kind);
            break;
        }
        case IncrementalProjectBuilder.AUTO_BUILD: {
            if (DEBUG) {
                System.out.println("AUTO BUILD");
            }
            doBuild(args, monitor, kind);
            break;
        }
        default: {

            FindbugsPlugin.getDefault()
            .logWarning("UKNOWN BUILD kind" + kind);
            doBuild(args, monitor, kind);
            break;
        }
        }
        return null;
    }