List of usage examples for java.util List containsAll
boolean containsAll(Collection<?> c);
From source file:Main.java
public static void main(String[] a) { List list = Arrays.asList(new String[] { "A", "B", "C", "D" }); List list1 = Arrays.asList(new String[] { "A", "B", "C", "D" }); System.out.println(list1.containsAll(list)); }
From source file:org.mitre.mpf.app.ComponentRegistrationApp.java
/** * Register one or more components. Updates the Algorithms.xml, Actions.xml, Tasks.xml, Pipelines.xml, * nodeServicesPalette.json, and nodeManagerConfig.xml files. * * @param args args[0] contains the path to the cpp component list; * args[1] contains the number of services per component that should be configured * args[2] contains the node manager hostname to use in nodeManagerConfig.xml * args[3] (optional) contains the string of user-specified components *///from www.j a va 2 s. c om public static void main(String[] args) { // NOTE: "-DcppComponents=<blank>" is the same as not providing the option if (args.length != 3 && args.length != 4) { System.err.println("Usage: java " + ComponentRegistrationApp.class.getSimpleName() + " component-list-file num-services-per-component node-manager-hostname [\"componentA,componentB,componentC,...\"]"); System.exit(-1); } String componentListPath = args[0]; if (!Files.exists(Paths.get(componentListPath))) { System.err.println("Cannot read: " + componentListPath); System.exit(-1); } List<String> componentPaths = null; try { componentPaths = Files.readAllLines(Paths.get(componentListPath), StandardCharsets.UTF_8); } catch (IOException e) { e.printStackTrace(); System.exit(-1); } int numServicesPerComponent = 1; try { numServicesPerComponent = Integer.parseInt(args[1]); } catch (NumberFormatException e) { e.printStackTrace(); System.exit(-1); } String nodeManagerHostname = args[2]; if (args.length == 4) { String componentsSpecified = args[3]; List<String> componentsSpecifiedList = Arrays.asList(componentsSpecified.split(",")); List<String> componentsSpecifiedInFileList = componentPaths.stream() .map(c -> FilenameUtils.getBaseName(c)).collect(Collectors.toList()); // sanity check if (!componentsSpecifiedInFileList.containsAll(componentsSpecifiedList)) { System.err.println( "The specified components " + componentsSpecifiedList + " are not a subset of those in " + componentListPath + " " + componentsSpecifiedInFileList + "."); System.err.println("Do a full MPF clean and build."); System.exit(-1); } // filter out components that were built, but should not be registered componentPaths = componentPaths.stream() .filter(c -> componentsSpecifiedList.contains(FilenameUtils.getBaseName(c))) .collect(Collectors.toList()); } // performance optimization: load the application context once ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext-minimal.xml"); AutowireCapableBeanFactory beanFactory = context.getAutowireCapableBeanFactory(); AddComponentService addComponentService = context.getBean(AddComponentService.class); beanFactory.autowireBean(addComponentService); NodeManagerService nodeManagerService = context.getBean(NodeManagerService.class); beanFactory.autowireBean(nodeManagerService); for (String componentPath : componentPaths) { // TODO: Handle caffe in the same way as the other components, then remove this check. // TODO: Ansible should prompt the user to install each and every component in the deployment package. String componentName = FilenameUtils.getBaseName(componentPath); if (componentName.equals("caffeComponent")) { continue; } String descriptorPath = componentPath + "/descriptor.json"; System.out.println("Registering: " + descriptorPath); try { // update Algorithms.xml, Actions.xml, Tasks.xml, Pipelines.xml, and nodeServicesPalette.json addComponentService.registerDeployedComponent(descriptorPath); } catch (Exception e) { e.printStackTrace(); System.exit(-1); // kill the build if anything goes wrong } } if (numServicesPerComponent > 0) { Map<String, ServiceModel> nodeServiceModels = nodeManagerService.getServiceModels(); for (ServiceModel serviceModel : nodeServiceModels.values()) { serviceModel.setServiceCount(numServicesPerComponent); } NodeManagerModel nodeManagerModel = new NodeManagerModel(nodeManagerHostname); nodeManagerModel.setServices(new ArrayList(nodeServiceModels.values())); List<NodeManagerModel> nodeManagerModels = new ArrayList<NodeManagerModel>(); nodeManagerModels.add(nodeManagerModel); try { // update nodeManagerConfig.xml nodeManagerService.saveNodeManagerConfig(nodeManagerModels, false); // don't reload NodeManagerStatus } catch (Exception e) { e.printStackTrace(); System.exit(-1); // kill the build if anything goes wrong } } }
From source file:Main.java
public static <T> boolean containsAll(List<T> c1, List<? extends T> c2) { return c1.containsAll(c2); }
From source file:Main.java
public static <T> boolean containsAll(List<? super T> c1, List<? extends T> c2) { return c1.containsAll(c2); }
From source file:Main.java
public static <T> boolean containsAll(List<? extends T> c1, List<? extends T> c2) { return c1.containsAll(c2); }
From source file:org.xdi.oxauth.model.authorize.AuthorizeParamsValidator.java
public static boolean validateResponseTypes(List<ResponseType> responseTypes, Client client) { if (responseTypes == null || responseTypes.isEmpty() || client == null || client.getResponseTypes() == null) { return false; }//from w w w . jav a 2 s. co m List<ResponseType> clientSupportedResponseTypes = Arrays.asList(client.getResponseTypes()); return clientSupportedResponseTypes.containsAll(responseTypes); }
From source file:Main.java
public static boolean containsAllAndOnly(List<?> c1, List<?> c2) { if (c1 == null || c2 == null) return false; if (c1.size() != c2.size()) return false; if (!c1.containsAll(c2)) return false; return true;//from w ww . jav a 2 s. c o m }
From source file:Main.java
public static boolean compareList(List<?> one, List<?> another) { if (one == null && another == null) { return true; } else if (one != null && another != null) { if (one.containsAll(another) && another.containsAll(one)) { return true; }//from ww w. j a v a 2 s . co m } return false; }
From source file:net.firejack.platform.core.utils.MiscUtils.java
public static <T> boolean elementEquals(List<T> list1, List<T> list2) { return (list2 == null && list1 == null) || (list2 != null && list1 != null && list2.containsAll(list1) && list1.containsAll(list2)); }
From source file:Main.java
public static <T> boolean listsEquals(List<T> list1, List<T> list2) { if (list1 == null) { return list2 == null || list2.isEmpty(); }//w w w . j a v a2 s. c o m if (list1.size() != list2.size()) { return false; } return list1.containsAll(list2); }