Converts the provided filter tree to a list of paths (array of filters). Each of the paths in the result
represent 1 branch from the tree from root to some leaf.

@param query the tree of filters
@return the list of paths
960590
public static Filter[][] filters(Query query) {
        List<List<Filter>> paths = new ArrayList<>();
        List<Filter[]> workingPath = new ArrayList<>();

        addPathsToLeaves(query, workingPath, paths);

        Filter[][] ret = new Filter[paths.size()][];
        Arrays.setAll(ret, (i) -> paths.get(i).toArray(new Filter[paths.get(i).size()]));
        return ret;
    }
1109346
public static List<File> pathsFiles(final String paths, final Predicate<File> predicate) {
        final List<File> files = new ArrayList<File>();
        for (final String filePathAndName : paths.split(File.pathSeparator)) {
            final File file = new File(filePathAndName);
            if (file.isDirectory()) {
                try (final Stream<Path> stream = Files.walk(file.toPath(), Integer.MAX_VALUE)) {
                    stream.map(f -> f.toFile()).filter(predicate).forEach(files::add);
                } catch (final IOException ex) {
                    throw new RuntimeException("Error walking path: " + file, ex);
                }
            } else {
                if (predicate.test(file)) {
                    files.add(file);
                }
            }
        }
        return files;
    }
470454
private List<?> getResultList(Query query) {
        // TODO : use lazy fetch here?
        if (projection != null) {
            List<?> results = query.getResultList();
            List<Object> rv = new ArrayList<Object>(results.size());
            for (Object o : results) {
                if (o != null) {
                    if (!o.getClass().isArray()) {
                        o = new Object[]{o};
                    }
                    rv.add(projection.newInstance((Object[]) o));
                } else {
                    rv.add(null);
                }
            }
            return rv;
        } else {
            return query.getResultList();
        }
    }
1070827
protected final List<T> findSortedByQuery(String query, String sort, Object... params) {
        return this.dataAccess.findSortedByQuery(query, sort, params);
    }
667898
public Pointer xpathPointer(Collection<?> collection, String query) {
    JXPathContext pathContext = JXPathContext.newContext(collection);
    Pointer result = null;

    try {
      result = pathContext.getPointer(query);
    } catch (JXPathNotFoundException e) {
      logger.warning(String.format("JXPath exception: %s", e.getMessage()));
    }

    return result;
  }
927591
public static List<Path> getSubPathList(Path startDirectoryPath,
			int maxDepth, Predicate<Path> filter) {
		List<Path> subPathList =
				Collections.synchronizedList(new ArrayList<>());
		if (isDirectory(startDirectoryPath))
			buildSubPath(startDirectoryPath, maxDepth, filter, subPathList);
		return subPathList;
	}
1138359
public List<FogbugzCase> searchForCases(String query) throws InvalidResponseException, NoSuchCaseException {
        HashMap<String, String> params = new HashMap<String, String>();  // Hashmap defaults to <String, String>
        params.put("cmd", "search");
        params.put("q", query);
        params.put("cols", "ixBug,tags,fOpen,sTitle,sFixFor,ixPersonOpenedBy,ixPersonAssignedTo" + // No trailing comma
                this.getCustomFieldsCSV());

        Document doc = null;
        try {
            doc = this.getFogbugzDocument(params);
        } catch (Exception e) {
            throw new InvalidResponseException(e.getMessage());
        }

        // Check for case count in cases tag, so we know wheter to parse the response ever further or not.
        int caseCount = 0;
        try {
            Node casesContainer = doc.getElementsByTagName("cases").item(0);
            caseCount = Integer.parseInt(casesContainer.getAttributes().getNamedItem("count").getTextContent());
        } catch (NumberFormatException e) {
            log.log(Level.INFO, "No valid number in case count XML response.", e);
        }
        if (caseCount < 1) {
            throw new NoSuchCaseException("Fogbugz did not return a case for query id " + query);
        }

        NodeList caseNodes = doc.getElementsByTagName("case");
        ArrayList<FogbugzCase> caseList = new ArrayList<FogbugzCase>();
        for (int i = 0; i < caseNodes.getLength(); i++) {
            caseList.add(this.constructCaseFromXmlNode(caseNodes.item(i)));
        }
        return caseList;
    }
475950
public static <T> Root<T> findRoot(CriteriaQuery<T> query) {
        return findRoot(query, query.getResultType());
    }
423000
private void convertToTermsQuery(FilterJoinNode node) {
    Map<String, Object> parent = node.getParentSourceMap();
    FilterJoinTerms terms = node.getTerms();
    BytesRef bytes = terms.getEncodedTerms();

    // Remove the filter join from the parent
    parent.remove(FilterJoinBuilder.NAME);

    // Create the nested object for the parameters of the field data terms query
    Map<String, Object> queryParams = new HashMap<>();
    queryParams.put("value", bytes.bytes);
    // use the hash of the filter join source map as cache key - see #170
    queryParams.put("_cache_key", node.getCacheId());

    // Create the nested object for the field
    Map<String, Object> field = new HashMap<>();
    field.put(node.getField(), queryParams);

    // Create the nested object for the field data terms query
    Map<String, Object> termsQuery = new HashMap<>();
    // If bytes terms encoding is used, we switch to the terms enum based terms query
    if (node.getTermsEncoding().equals(TermsByQueryRequest.TermsEncoding.BYTES)) {
      termsQuery.put(TermsEnumTermsQueryParser.NAME, field);
    }
    else {
      termsQuery.put(FieldDataTermsQueryParser.NAME, field);
    }

    // Create the object for the constant score query
    Map<String, Object> constantScoreQueryParams = new HashMap<>();
    constantScoreQueryParams.put("filter", termsQuery);

    // Add the constant score query to the parent
    parent.put(ConstantScoreQueryParser.NAME, constantScoreQueryParams);
    node.setState(FilterJoinNode.State.CONVERTED);
    this.blockingQueue.poll();
  }
824127
protected function resolvePathAndQuery(string $path, string $query): array
    {
        $components = ['path' => $path, 'query' => $query];

        if ('' === $components['path']) {
            $components['path'] = $this->base_uri->getPath();
            if ('' === $components['query']) {
                $components['query'] = $this->base_uri->getQuery();
            }

            return $components;
        }

        if (0 !== strpos($components['path'], '/')) {
            $components['path'] = $this->mergePath($components['path']);
        }

        return $components;
    }
1030842
@SuppressWarnings({ "unchecked" })
    private Predicate convertParametersToPredicate(Root<?> from, CriteriaQuery<?> query) {
        List<Predicate> predicates = new ArrayList<>();
        for (Map.Entry<String, Set<Object>> value : request.getParameters().entrySet()) {
            Subquery<JPAEntry> subquery = buildJPAEntrySubquery(value.getKey(), value.getValue(), from, query);
            predicates.add(builder.exists(subquery));
        }
        if (request.isAndJoined()) {
            return builder.and(Iterables.toArray(predicates, Predicate.class));
        } else {
            return builder.or(Iterables.toArray(predicates, Predicate.class));
        }
    }
106302
public static Map<String, String> parseQuery(String query) {
		Map<String, String> result = new LinkedHashMap<String, String>();
		
		if (query != null) {
			for (String keyValue: query.split("&")) {
				String[] pair = keyValue.split("=");
				result.put(StringUtils.urlDecode(pair[0]), StringUtils.urlDecode(pair[1]));
			}
		}
		
		return result;
	}
1068836
public static <T> Root<T> findRoot(CriteriaQuery<?> query, Class<T> clazz) {

        for (Root<?> r : query.getRoots()) {
            if (clazz.equals(r.getJavaType())) {
                return (Root<T>) r.as(clazz);
            }
        }
        return null;
    }
455837
public static List<ModelServiceInstance> filter(ServiceInstanceQuery query, List<ModelServiceInstance> list) {

        List<ModelServiceInstance> instances = new ArrayList<ModelServiceInstance>();
        for (ModelServiceInstance instance : list) {
            boolean passed = true;
            for (QueryCriterion criterion : query.getCriteria()) {
                if (criterion.isMatch(instance.getMetadata()) == false) {
                    passed = false;
                    break;
                }
            }
            if (passed) {
                instances.add(instance);
            }
        }
        return instances;

    }
1103081
public static List<TreePath> computeExpandedPaths(JTree tree)
    {
        List<TreePath> treePaths = new ArrayList<TreePath>();
        int rows = tree.getRowCount();
        for (int i = 0; i < rows; i++)
        {
            TreePath treePath = tree.getPathForRow(i);
            treePaths.add(treePath);
        }
        return treePaths;
    }
752081
public static FilterFragment[] from(Filter... filters) {
        FilterFragment[] ret = new FilterFragment[filters.length];
        Arrays.setAll(ret, (i) -> new FilterFragment(filters[i]));
        return ret;
    }
124266
public MongoDeepJobConfig<T> filterQuery(Filter[] filters) {

        if (filters.length > 0) {
            List<BasicDBObject> list = new ArrayList<>();

            QueryBuilder queryBuilder = QueryBuilder.start();
            for (int i = 0; i < filters.length; i++) {
                BasicDBObject bsonObject = new BasicDBObject();

                Filter filter = filters[i];
                if (filter.getFilterType().equals(FilterType.EQ)) {
                    bsonObject.put(filter.getField(), filter.getValue());
                } else {
                    bsonObject.put(filter.getField(),
                            new BasicDBObject("$".concat(filter.getFilterType().getFilterTypeId().toLowerCase()),
                                    filter.getValue()));
                }

                list.add(bsonObject);
            }
            queryBuilder.and(list.toArray(new BasicDBObject[list.size()]));

            filterQuery(queryBuilder);
        }
        return this;

    }