Convert a {@link List} of local {@link Condition}s into an array of
WSDL-style {@link org.fcrepo.server.types.gen.Condition Condition}s.
431526
public static List<org.fcrepo.server.types.gen.Condition> convertConditionsListToGenConditionsArray(List<Condition> conditions) {
        List<org.fcrepo.server.types.gen.Condition> genConditions =
                new ArrayList<org.fcrepo.server.types.gen.Condition>();

        for (Condition condition : conditions) {
            genConditions.add(convertConditionToGenCondition(condition));
        }

        return genConditions;
    }
1326269
private Map<String, ConditionsByKey> groupConditionsByTypeAndKey(
            List<Condition> conditions) {
        Map<String, ConditionsByKey> conditionsByType = new LinkedHashMap<String, ConditionsByKey>();

        String type;
        String key;
        ConditionsByKey conditionsByKey;
        for (Condition condition : conditions) {
            type = condition.getType();
            key = condition.getConditionKey();

            if (!(conditionsByType.containsKey(type))) {
                conditionsByType.put(type, new ConditionsByKey());
            }

            conditionsByKey = conditionsByType.get(type);
            conditionsByKey.addValuesToKey(key, condition.getValues());
        }
        return conditionsByType;
    }
420039
def filter(*conditions)
      latest = !conditions.select {|item| item === true }.empty?
      filters = translate_conditions(conditions)
      items = list(latest)
      unless filters.empty?
        items = items.select do |item|
          !filters.select {|filter| match_filter(filter, item) }.empty?
        end

      end
      items
    end
378555
public Collection<PluginsAlertCondition> list(List<String> queryParams)
    {
        return HTTP.GET("/v2/alerts_plugins_conditions.json", null, queryParams, PLUGINS_ALERT_CONDITIONS).get();
    }
410900
public static function splitNestedConditions($conditionList, $charset = "UTF-8")
    {
        // Check arguments
        if (!is_string($conditionList)) {
            throw new \InvalidArgumentException(
                "Invalid type '" . gettype($conditionList). "' for argument 'conditionList' given."
            );
        }
        if (!is_string($charset)) {
            throw new \InvalidArgumentException(
                "Invalid type '" . gettype($charset). "' for argument 'charset' given."
            );
        } elseif (!in_array($charset, mb_list_encodings())) {
            throw new \InvalidArgumentException(
                "Invalid value '" . $charset . "' for argument 'charset' given. Charset not supported."
            );
        }

        // Remove at-rule and unnecessary white-spaces
        $conditionList = trim($conditionList, " \r\n\t\f");

        // Strings and comments should already be replaced, but let's check it again...
        $conditionList = Placeholder::replaceStringsAndComments($conditionList);

        $inFunction = false;
        $groupsOpened = 0;
        $enclosedChar = null;

        $conditions = [];
        $currentConditions = [""];
        $currentConditionKeys = [0];
        $subConditionList = "";

        if (preg_match('/[^\x00-\x7f]/', $conditionList)) {
            $isAscii = false;
            $strLen  = mb_strlen($conditionList, $charset);
            $getOr  = function($i) use ($conditionList){return strtolower(substr($conditionList, $i, 4));};
        } else {
            $isAscii = true;
            $strLen = strlen($conditionList);
            $getOr  = function($i) use ($charset, $conditionList){
                return mb_strtolower(mb_substr($conditionList, $i, 4, $charset), $charset);
            };
        }

        for ($i = 0, $j = $strLen; $i < $j; $i++) {
            if ($isAscii === true) {
                $char = $conditionList[$i];
            } else {
                $char = mb_substr($conditionList, $i, 1, $charset);
            }

            if ($char === "(") {
                if ($groupsOpened > 0) {
                    $subConditionList .= $char;
                } else {
                    if ($i > 0) {
                        $prevChar = mb_substr($conditionList, ($i - 1), 1, $charset);
                        if ($prevChar !== "(" && $prevChar !== " ") {
                            $inFunction = true;
                        }
                    }
                }

                if ($inFunction === false) {
                    $groupsOpened++;
                } else {
                    foreach ($currentConditionKeys as $index) {
                        $currentConditions[$index] .= $char;
                    }
                }
            } elseif ($char === ")") {
                if ($inFunction === false) {
                    $groupsOpened--;
                    if ($groupsOpened > 0) {
                        $subConditionList .= $char;
                    } else {
                        if ($subConditionList != "") {
                            $subConditions = self::splitNestedConditions($subConditionList, $charset);
                            $newConditions = [];
                            foreach ($subConditions as $subCondition) {
                                foreach ($currentConditions as $currentCondition) {
                                    $newConditions[] = trim($currentCondition, " \r\n\t\f") . " " . $subCondition;
                                }
                            }
                            $currentConditions = $newConditions;
                            $currentConditionKeys = array_keys($currentConditions);
                        }
                        $subConditionList = "";
                    }
                } else {
                    if ($groupsOpened > 0) {
                        $subConditionList .= $char;
                    }
                    foreach ($currentConditionKeys as $index) {
                        $currentConditions[$index] .= $char;
                    }
                    $inFunction = false;
                }
            } elseif ($char === " " && $getOr($i) === " or ") {
                if ($groupsOpened > 0) {
                    $subConditionList .= " or ";
                } else {
                    foreach ($currentConditions as $currentCondition) {
                        $conditions[] = trim($currentCondition, " \r\n\t\f");
                    }
                    $currentConditions = [""];
                    $currentConditionKeys = [0];
                }
                $i += (4 - 1);
            } else {
                if ($groupsOpened > 0) {
                    $subConditionList .= $char;
                } else {
                    foreach ($currentConditionKeys as $index) {
                        $currentConditions[$index] .= $char;
                    }
                }
            }
        }
        foreach ($currentConditions as $currentCondition) {
            $conditions[] = trim($currentCondition, " \r\n\t\f");
        }

        return $conditions;
    }
1264349
public static <T> List<LocalProperty<T>> normalizeAndPrune(List<? extends LocalProperty<T>> localProperties)
    {
        return normalize(localProperties).stream()
                .filter(Optional::isPresent)
                .map(Optional::get)
                .collect(Collectors.toList());
    }
1278770
private static void getConditionNodes(final Node node, final Map<Node, List<String>> conditionalNodes) {
        final NamedNodeMap attributes = node.getAttributes();
        if (attributes != null) {
            final Node attr = attributes.getNamedItem("condition");

            if (attr != null) {
                final String conditionStatement = attr.getNodeValue();

                final String[] conditions = conditionStatement.split("\\s*(;|,)\\s*");

                conditionalNodes.put(node, Arrays.asList(conditions));
            }
        }

        // Check the child nodes for condition attributes
        final NodeList elements = node.getChildNodes();
        for (int i = 0; i < elements.getLength(); ++i) {
            getConditionNodes(elements.item(i), conditionalNodes);
        }
    }
292555
public static List<Condition> getConditions(String query)
            throws QueryParseException {
        StringBuffer prop = new StringBuffer();
        Operator oper = null;
        StringBuffer val = new StringBuffer();
        ArrayList<Condition> ret = new ArrayList<Condition>();
        boolean inProp = true;
        boolean inValue = false;
        boolean firstValueChar = false;
        boolean valueStartsWithQuote = false;
        for (int i = 0; i < query.length(); i++) {
            char c = query.charAt(i);
            if (inProp) {
                if (c == '=') {
                    oper = Operator.EQUALS;
                    inProp = false;
                    inValue = true;
                    firstValueChar = true;
                } else if (c == '~') {
                    oper = Operator.CONTAINS;
                    inProp = false;
                    inValue = true;
                    firstValueChar = true;
                } else if (c == '>') {
                    if (i + 1 < query.length()) {
                        char d = query.charAt(i + 1);
                        if (d == '=') {
                            i++;
                            oper = Operator.GREATER_OR_EQUAL;
                        } else {
                            oper = Operator.GREATER_THAN;
                        }
                        inProp = false;
                        inValue = true;
                        firstValueChar = true;
                    } else {
                        throw new QueryParseException("Found <end-of-string> "
                                + "immediately following '>' operator, but "
                                + "expected a value.");
                    }
                } else if (c == '<') {
                    if (i + 1 < query.length()) {
                        char d = query.charAt(i + 1);
                        if (d == '=') {
                            i++;
                            oper = Operator.LESS_OR_EQUAL;
                        } else {
                            oper = Operator.LESS_THAN;
                        }
                        inProp = false;
                        inValue = true;
                        firstValueChar = true;
                    } else {
                        throw new QueryParseException("Found <end-of-string> "
                                + "immediately following '<' operator, but "
                                + "expected a value.");
                    }
                } else if ((c >= 0x41 && c <= 0x5A) || (c >= 0x61 && c <= 0x7A)) {
                    prop.append(c);
                } else {
                    throw new QueryParseException("Found ' " + c
                            + "' at character " + i
                            + " but expected operator");
                }
            } else if (inValue) {
                if (prop.toString().length() == 0) {
                    throw new QueryParseException("Found "
                            + "operator but expected a non-zero length "
                            + "property.");
                }
                if (firstValueChar) {
                    // allow ', and mark it if it's there, add one to i
                    if (c == '\'') {
                        i++;
                        if (i >= query.length()) {
                            throw new QueryParseException("Found <end-of-string> "
                                    + "immediately following start quote, but "
                                    + "expected a value.");
                        }
                        c = query.charAt(i);
                        valueStartsWithQuote = true;
                    }
                    firstValueChar = false;
                }
                if (c == '\'') {
                    if (!valueStartsWithQuote) {
                        throw new QueryParseException("Found ' character in "
                                + "value at position " + i + ", but the value "
                                + "did not start with a string, so this can't "
                                + " be a value terminator.");
                    }
                    // end of value part
                    // next must be space or empty... check
                    i++;
                    if (i < query.length()) {
                        if (query.charAt(i) != ' ') {
                            throw new QueryParseException("Found value-terminator "
                                    + "' but it was not followed by <end-of-string> "
                                    + "or <space>.");
                        }
                    }
                    ret
                            .add(new Condition(prop.toString(), oper, val
                                    .toString()));
                    prop = new StringBuffer();
                    oper = null;
                    val = new StringBuffer();
                    inValue = false;
                    inProp = true;
                    valueStartsWithQuote = false;
                } else if (c == '\\') {
                    i++;
                    if (i >= query.length()) {
                        throw new QueryParseException("Found character-escaping "
                                + "character as last item in string.");
                    }
                    val.append(query.charAt(i));
                } else if (c == ' ') {
                    // end of value part... or inside string?
                    if (valueStartsWithQuote) {
                        // was inside string..ok
                        val.append(c);
                    } else {
                        // end of value part...cuz not quotes
                        ret.add(new Condition(prop.toString(), oper, val
                                .toString()));
                        prop = new StringBuffer();
                        oper = null;
                        val = new StringBuffer();
                        inValue = false;
                        inProp = true;
                    }
                } else if (c == '=') {
                    throw new QueryParseException("Found <operator> at position "
                            + i + ", but expected <value>");
                } else if (c == '~') {
                    throw new QueryParseException("Found <operator> at position "
                            + i + ", but expected <value>");
                } else if (c == '>') {
                    throw new QueryParseException("Found <operator> at position "
                            + i + ", but expected <value>");
                } else if (c == '<') {
                    throw new QueryParseException("Found <operator> at position "
                            + i + ", but expected <value>");
                } else {
                    val.append(c);
                }
            }
        }
        if (inProp) {
            if (prop.toString().length() > 0) {
                throw new QueryParseException("String ended before operator "
                        + "was found");
            }
        }
        if (inValue) {
            if (valueStartsWithQuote) {
                throw new QueryParseException("String ended before quoted value"
                        + "'s ending quote.");
            }
            ret.add(new Condition(prop.toString(), oper, val.toString()));
        }
        return ret;
    }
229699
public static org.fcrepo.server.types.gen.FieldSearchQuery convertFieldSearchQueryToGenFieldSearchQuery(FieldSearchQuery fsq) {
        List<org.fcrepo.server.types.gen.Condition> genConditions =
                fsq.getConditions() == null ? null
                        : convertConditionsListToGenConditionsArray(fsq
                                .getConditions());
        org.fcrepo.server.types.gen.FieldSearchQuery query = new org.fcrepo.server.types.gen.FieldSearchQuery();

        ObjectFactory factory = new ObjectFactory();
        org.fcrepo.server.types.gen.FieldSearchQuery.Conditions conds = new org.fcrepo.server.types.gen.FieldSearchQuery.Conditions();
        conds.getCondition().addAll(genConditions);
        query.setConditions(factory.createFieldSearchQueryConditions(conds));
        return query;
    }
770248
public static Condition in(String name, Object... values) {
        List<Condition> conditions = new ArrayList<Condition>();
        for (Object value : values) {
            conditions.add(eq(name, value));
        }
        return or(conditions.toArray(new Condition[conditions.size()]));
    }
441790
public static <E> List<E> compact(final List<E> list) {
        return filter(list, new Predicate<E>() {
            @Override
            public boolean test(E arg) {
                return !String.valueOf(arg).equals("null") && !String.valueOf(arg).equals("0")
                    && !String.valueOf(arg).equals("false") && !String.valueOf(arg).equals("");
            }
        });
    }
83817
private <E> List<E> cons(E value, List<E> list) {
        List<E> result = new ArrayList<E>(list.size() + 1);
        result.add(value);
        result.addAll(list);
        return result;
    }
783148
function parse_where_type_condition_array(query, type) {
	var predicates = ARRAY(type).map(function(t) {
		if(is.string(t)) {
			return new Predicate("type = $", t);
		}
		if(type instanceof NoPg.Type) {
			return new Predicate("types_id = $", type.$id);
		}
		throw new TypeError("Unknown type: " + util.inspect(t));
	}).valueOf();
	query.where( Predicate.join(predicates, 'OR') );
}
194943
public static List<ModelServiceInstance> filter(ServiceInstanceQuery query, List<ModelServiceInstance> list) {

        if (list == null || list.size() == 0) {
            return Collections.emptyList();
        }

        List<QueryCriterion> criteria = query.getCriteria();

        if (criteria == null || criteria.size() == 0) {
            return list;
        }

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

        return instances;

    }
572426
public static List<Condition> extractConditions(String alias, final Entity<?> entity) {
    if (null == entity) { return Collections.emptyList(); }
    final List<Condition> conditions = new ArrayList<Condition>();

    StringBuilder aliasBuilder = new StringBuilder(alias == null ? "" : alias);
    if (aliasBuilder.length() > 0 && !alias.endsWith(".")) aliasBuilder.append(".");
    alias = aliasBuilder.toString();
    String attr = "";
    try {
      final Set<String> props = PropertyUtils.getWritableProperties(entity.getClass());
      for (final Iterator<String> iter = props.iterator(); iter.hasNext();) {
        attr = iter.next();
        final Object value = PropertyUtils.getProperty(entity, attr);
        if (null == value) continue;
        if (!(value instanceof Collection<?>)) addAttrCondition(conditions, alias + attr, value);
      }
    } catch (Exception e) {
      logger.debug("error occur in extractConditions for  bean {} with attr named {}", entity, attr);
    }
    return conditions;
  }
189698
public void addCondition(final Condition condition) {
        if (conditions_ == null) {
            conditions_ = new ArrayList<>();
        }
        conditions_.add(condition);
    }
1148251
public SDVariable matchCondition(SDVariable in, Condition condition) {
        return matchCondition(null, in, condition);
    }