code: 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;
  
      }
docs: Filter the ModelServiceInstance list against the ServiceInstanceQuery.
  
  @param query
  the ServiceInstanceQuery matchers.
  @param list
  the ModelServiceInstance list.
  @return
  the matched ModelServiceInstance list.