Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (c) 2013-2014 by Cisco Systems, Inc. All rights reserved.
  
  package com.cisco.oss.foundation.directory.impl;
  
  import java.util.List;
 
The helper class to do the ServiceInstances filter against the QueryCriterion.

Author(s):
zuxiang
 
 public class ServiceInstanceQueryHelper {

Filter the ModelServiceInstance list against the ServiceInstanceQuery.

Parameters:
query the ServiceInstanceQuery matchers.
list the ModelServiceInstance list.
Returns:
the matched ModelServiceInstance list.
 
 
 		if (list == null || list.size() == 0) {
 			return Collections.emptyList();
 		}
 
 		List<QueryCriterioncriteria = query.getCriteria();
 		
 		if (criteria == null || criteria.size() == 0) {
 			return list;
 		}
 
 		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;
 
 	}

Filter the ServiceInstance list against the ServiceInstanceQuery.

Parameters:
query the ServiceInstanceQuery matchers.
list the ServiceInstance list.
Returns:
the matched ServiceInstance list.
 
 
 		if (list == null || list.size() == 0) {
 			return Collections.emptyList();
 		}
 
 		List<QueryCriterioncriteria = query.getCriteria();
 		
 		if (criteria == null || criteria.size() == 0) {
 			return list;
 		}
 
 		List<ServiceInstanceinstances = new ArrayList<ServiceInstance>();
 		for (ServiceInstance 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;
	}
New to GrepCode? Check out our FAQ X