Filter the ModelServiceInstance list against the ServiceInstanceQuery.

@param query
the ServiceInstanceQuery matchers.
@param list
the ModelServiceInstance list.
@return
the matched ModelServiceInstance list.
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;

    }
655770
@Override
    public Set<QueryableEntry<K, V>> filter(QueryContext queryContext) {
        if (!(predicate instanceof IndexAwarePredicate)) {
            return null;
        }

        Set<QueryableEntry<K, V>> set = ((IndexAwarePredicate<K, V>) predicate).filter(queryContext);
        if (set == null || set.isEmpty()) {
            return set;
        }
        List<QueryableEntry<K, V>> resultList = new ArrayList<QueryableEntry<K, V>>();
        Map.Entry<Integer, Map.Entry> nearestAnchorEntry = getNearestAnchorEntry();
        for (QueryableEntry<K, V> queryableEntry : set) {
            if (SortingUtil.compareAnchor(this, queryableEntry, nearestAnchorEntry)) {
                resultList.add(queryableEntry);
            }
        }

        List<QueryableEntry<K, V>> sortedSubList =
                (List) SortingUtil.getSortedSubList((List) resultList, this, nearestAnchorEntry);
        return new LinkedHashSet<QueryableEntry<K, V>>(sortedSubList);
    }
913126
@SuppressWarnings(UNCHECKED)
    protected List<E> list(Query query)
    {
        return new ArrayList<E>(query.list());
    }
170387
public PactDslRequestWithPath matchQuery(String parameter, String regex, List<String> example) {
        requestMatchers.addCategory("query").addRule(parameter, new RegexMatcher(regex));
        query.put(parameter, example);
        return this;
    }
292984
public static List<String> getColumnListFromQuery(String query) {
    if (Strings.isNullOrEmpty(query)) {
      return null;
    }
    String queryLowerCase = query.toLowerCase();
    int startIndex = queryLowerCase.indexOf("select ") + 7;
    int endIndex = queryLowerCase.indexOf(" from ");
    if (startIndex < 0 || endIndex < 0) {
      return null;
    }
    String[] inputQueryColumns = query.substring(startIndex, endIndex).toLowerCase().replaceAll(" ", "").split(",");
    return Arrays.asList(inputQueryColumns);
  }
838929
@Override
    @SuppressWarnings("unchecked")
    public <T> List<T> getResultList(JPAQuery<T> query, Expression<T> projection) {
        Query jpaQuery = query.createQuery();

        if (jpaQuery instanceof QueryImpl) {
            QueryImpl casted = (QueryImpl) jpaQuery;
            if (casted.getDatabaseQuery() instanceof ObjectLevelReadQuery) {
                Field f = ReflectionUtils.findField(ObjectLevelReadQuery.class, "joinedAttributeManager");
                f.setAccessible(true);
                JoinedAttributeManager old = (JoinedAttributeManager) ReflectionUtils.getField(f, casted.getDatabaseQuery());
                if (old != null) {
                    FixedJoinerAttributeManager newManager = new FixedJoinerAttributeManager(old.getDescriptor(), old.getBaseExpressionBuilder(),
                            old.getBaseQuery());
                    newManager.copyFrom(old);
                    ReflectionUtils.setField(f, casted.getDatabaseQuery(), newManager);
                }
            }
        }

        if (projection instanceof FactoryExpression) {
            FactoryExpression factoryExpression = (FactoryExpression) projection;

            List<?> results = jpaQuery.getResultList();
            List<Object> rv = new ArrayList<>(results.size());
            for (Object o : results) {
                if (o != null) {
                    if (!o.getClass().isArray()) {
                        o = new Object[]{o};
                    }
                    rv.add(factoryExpression.newInstance((Object[]) o));
                } else {
                    rv.add(null);
                }
            }
            return (List<T>) rv;
        } else {
            return jpaQuery.getResultList();
        }
    }
651335
public Map<String, List<String>> parseQuery(String query)
    {
        Map<String, List<String>> queryParams = new LinkedHashMap<>();
        if (query != null) {
            for (NameValuePair params : URLEncodedUtils.parse(query, StandardCharsets.UTF_8)) {
                String name = params.getName();
                List<String> values = queryParams.get(name);
                if (values == null) {
                    values = new ArrayList<>();
                    queryParams.put(name, values);
                }
                values.add(params.getValue());
            }
        }
        return queryParams;
    }
1350983
public static Call.Mapper<List<List<Span>>, List<List<Span>>> create(QueryRequest request) {
    return new FilterTraces(request);
  }
1117582
public static List<Map> findAll(String query) {
        return new DB(DB.DEFAULT_NAME).findAll(query);
    }
118931
static List<JmxData> query(MBeanServer server, ObjectName query) throws Exception {
    List<JmxData> data = new ArrayList<>();

    Set<ObjectName> names = server.queryNames(query, null);
    LOGGER.trace("query [{}], found {} matches", query, names.size());
    for (ObjectName name : names) {
      MBeanInfo info = server.getMBeanInfo(name);
      MBeanAttributeInfo[] attrs = info.getAttributes();
      String[] attrNames = new String[attrs.length];
      for (int i = 0; i < attrs.length; ++i) {
        attrNames[i] = attrs[i].getName();
      }

      Map<String, String> stringAttrs = new HashMap<>();
      stringAttrs.put("domain", name.getDomain());
      Map<String, Number> numberAttrs = new HashMap<>();

      for (Attribute attr : server.getAttributes(name, attrNames).asList()) {
        Object obj = attr.getValue();
        if (LOGGER.isTraceEnabled()) {
          LOGGER.trace("attribute [{}][{}] = {}", name, attr.getName(), mkString(obj));
        }

        if (obj instanceof String) {
          stringAttrs.put(attr.getName(), (String) obj);
        } else if (obj instanceof Number) {
          numberAttrs.put(attr.getName(), ((Number) obj).doubleValue());
        } else if (obj instanceof CompositeDataSupport) {
          CompositeDataSupport composite = (CompositeDataSupport) obj;
          CompositeType compositeType = composite.getCompositeType();
          for (String key : compositeType.keySet()) {
            if (composite.containsKey(key)) {
              Object o = composite.get(key);
              String attrKey = attr.getName() + "." + key;
              if (o instanceof Number) {
                numberAttrs.put(attrKey, ((Number) o).doubleValue());
              } else if (o instanceof String) {
                stringAttrs.put(attrKey, (String) o);
              } else if (o instanceof TimeUnit) {
                stringAttrs.put(attrKey, o.toString());
              }
            }
          }
        } else if (obj instanceof TimeUnit) {
          stringAttrs.put(attr.getName(), obj.toString());
        }
      }

      // Add properties from ObjectName after attributes to ensure they have a higher
      // priority if the same key is used both in the Object and as an attribute
      stringAttrs.putAll(name.getKeyPropertyList());

      data.add(new JmxData(name, stringAttrs, numberAttrs));
    }

    return data;
  }
931621
async def list(self, *, filters: Mapping = None) -> List[Mapping]:
        

        params = {"filters": clean_filters(filters)}

        response = await self.docker._query_json(
            "services", method="GET", params=params
        )
        return response
265781
private FilterList getFilterList(Filter filters)
    {
        FilterList filterList = null;
        if (filters != null)
        {
            if (FilterList.class.isAssignableFrom(filters.getClass()))
            {
                filterList = (FilterList) filters;
            }
            else
            {
                filterList = new FilterList();
                filterList.addFilter(filters);
            }
        }
        return filterList;
    }
1052291
public <T> List<T> search(org.beangle.commons.dao.query.Query<T> query) {
    if (query instanceof LimitQuery) {
      org.beangle.commons.dao.query.LimitQuery<T> limitQuery = (org.beangle.commons.dao.query.LimitQuery<T>) query;
      if (null == limitQuery.getLimit()) {
        return QuerySupport.find(limitQuery, getSession());
      } else {
        return new SinglePage<T>(limitQuery.getLimit().getPageIndex(), limitQuery.getLimit().getPageSize(),
            QuerySupport.count(limitQuery, getSession()), QuerySupport.find(query, getSession()));
      }
    } else {
      return QuerySupport.find(query, getSession());
    }
  }
603680
@Override
    public List<ServiceRef> getServiceRefs() {
        List<ServiceRef> returnValue = delegate == null ? new ArrayList<ServiceRef>() : new ArrayList<ServiceRef>(delegate.getServiceRefs());

        returnValue.addAll(serviceRefTypeMap.values());
        returnValue.addAll(ejbServiceRefTypeMap.values());

        return returnValue;
    }
762286
public List<ModelServiceInstance> queryService(List<StringCommand> commands){

        ProtocolHeader header = new ProtocolHeader();
        header.setType(ProtocolType.QueryService);

        List<QueryCommand> cs = new ArrayList<QueryCommand>();
        for(StringCommand c : commands){
            cs.add(c.getStringCommand());
        }

        QueryServiceProtocol p = new QueryServiceProtocol(cs);
        QueryServiceResponse resp ;
        resp = (QueryServiceResponse) connection.submitRequest(header, p,  null);
        return resp.getInstances();
    }
1054005
public final List<T> findByQuery(String query, Object... params) {
        return this.findSortedByQuery(query, null, params);
    }
467093
protected List<E> list(CriteriaQuery<E> criteria) throws HibernateException {
        return currentSession().createQuery(requireNonNull(criteria)).getResultList();
    }