List of usage examples for java.util Set containsAll
boolean containsAll(Collection<?> c);
From source file:com.hortonworks.streamline.streams.layout.storm.StormTopologyValidator.java
private void validateRuleProcessorLinks() throws ComponentConfigException { List<Map> dataSources = (List) this.topologyConfig.get(TopologyLayoutConstants.JSON_KEY_DATA_SOURCES); Set<String> dataSourceNames = new HashSet<>(); for (Map dataSource : dataSources) { dataSourceNames.add((String) dataSource.get(TopologyLayoutConstants.JSON_KEY_UINAME)); }// w w w . j a v a 2 s .c om List<Map> processors = (List) this.topologyConfig.get(TopologyLayoutConstants.JSON_KEY_PROCESSORS); Map<String, Map<String, Set<String>>> ruleProcessors = new LinkedHashMap<>(); for (Map processor : processors) { String type = (String) processor.get(TopologyLayoutConstants.JSON_KEY_TYPE); if ("RULE".equals(type)) { Map config = (Map) processor.get(TopologyLayoutConstants.JSON_KEY_CONFIG); Map ruleProcessorConfig = (Map) config.get(TopologyLayoutConstants.JSON_KEY_RULES_PROCESSOR_CONFIG); Map<String, Set<String>> ruleInfo = this .getRuleProcessorStreamIdsToOutputFields(ruleProcessorConfig); ruleProcessors.put((String) processor.get(TopologyLayoutConstants.JSON_KEY_UINAME), ruleInfo); } } Set<String> ruleProcessorKeys = ruleProcessors.keySet(); List<Map> links = (List) this.topologyConfig.get(TopologyLayoutConstants.JSON_KEY_LINKS); for (Map link : links) { Map linkConfig = (Map) link.get(TopologyLayoutConstants.JSON_KEY_CONFIG); String from = (String) linkConfig.get(TopologyLayoutConstants.JSON_KEY_FROM); String to = (String) linkConfig.get(TopologyLayoutConstants.JSON_KEY_TO); if (ruleProcessorKeys.contains(from)) { String streamId = (String) linkConfig.get(TopologyLayoutConstants.JSON_KEY_STREAM_ID); if (StringUtils.isEmpty(streamId)) { throw new ComponentConfigException( String.format(TopologyLayoutConstants.ERR_MSG_INVALID_STREAM_ID, link.get(TopologyLayoutConstants.JSON_KEY_UINAME))); } Map<String, Set<String>> streamIdToOutput = ruleProcessors.get(from); Set<String> ruleStreams = streamIdToOutput.keySet(); if (!ruleStreams.contains(streamId)) { throw new ComponentConfigException( String.format(TopologyLayoutConstants.ERR_MSG_INVALID_STREAM_ID, link.get(TopologyLayoutConstants.JSON_KEY_UINAME))); } if ("FIELDS".equals(link.get(TopologyLayoutConstants.JSON_KEY_TYPE))) { Set<String> outputFields = streamIdToOutput.get(streamId); List<String> groupingFields = (List) linkConfig .get(TopologyLayoutConstants.JSON_KEY_GROUPING_FIELDS); if (!outputFields.containsAll(groupingFields)) { throw new ComponentConfigException( String.format(TopologyLayoutConstants.ERR_MSG_INVALID_GROUPING_FIELDS, link.get(TopologyLayoutConstants.JSON_KEY_UINAME))); } } } if (ruleProcessorKeys.contains(to)) { // link to a rule processor can not go from a data source if (dataSourceNames.contains(from)) { throw new ComponentConfigException( String.format(TopologyLayoutConstants.ERR_MSG_INVALID_LINK_TO_PROCESSOR, link.get(TopologyLayoutConstants.JSON_KEY_UINAME))); } } } }
From source file:br.usp.poli.lta.cereda.aa.model.Submachine.java
/** * Construtor. Define a estrutura da submquina como um todo. * @param name Nome da submquina./*from ww w . j av a2s . c o m*/ * @param states Conjunto de todos os estados da submquina. * @param initialState Estado inicial ou de entrada da submquina. * @param acceptingStates Conjunto de estados finais ou de aceitao. */ public Submachine(String name, Set<State> states, State initialState, Set<State> acceptingStates) { this.identifier = IdentifierUtils.getSubmachineIdentifier(); this.name = name; this.initialState = initialState; this.acceptingStates = acceptingStates; this.states = states; // valida se todos os estados definidos esto de acordo com a teoria Validate.isTrue(states.contains(initialState) && states.containsAll(acceptingStates), "Existem estados indefinidos na submquina '".concat(String.valueOf(name).concat("'."))); }
From source file:Main.java
static <E> Set<E> ungrowableSet(final Set<E> s) { return new Set<E>() { @Override//from www .ja v a 2 s . co m public int size() { return s.size(); } @Override public boolean isEmpty() { return s.isEmpty(); } @Override public boolean contains(Object o) { return s.contains(o); } @Override public Object[] toArray() { return s.toArray(); } @Override public <T> T[] toArray(T[] a) { return s.toArray(a); } @Override public String toString() { return s.toString(); } @Override public Iterator<E> iterator() { return s.iterator(); } @Override public boolean equals(Object o) { return s.equals(o); } @Override public int hashCode() { return s.hashCode(); } @Override public void clear() { s.clear(); } @Override public boolean remove(Object o) { return s.remove(o); } @Override public boolean containsAll(Collection<?> coll) { return s.containsAll(coll); } @Override public boolean removeAll(Collection<?> coll) { return s.removeAll(coll); } @Override public boolean retainAll(Collection<?> coll) { return s.retainAll(coll); } @Override public boolean add(E o) { throw new UnsupportedOperationException(); } @Override public boolean addAll(Collection<? extends E> coll) { throw new UnsupportedOperationException(); } }; }
From source file:xc.mst.services.marcaggregation.matcher.SystemControlNumberMatcher.java
public boolean matchpointsHaveChanged(SaxMarcXmlRecord r, InputRecord ir) { LOG.debug("Sccn matchpointsHaveChanged? ID: " + ir.getId()); Map<Long, List<SCNData>> cachedListId2scn = getMAS().getMarcAggregationServiceDAO() .getSCCNRecordsCache(Long.valueOf(ir.getId())); LOG.debug("cachedListId2scn: " + cachedListId2scn); List<SCNData> cachedId2scn = new ArrayList<SCNData>(); if (cachedListId2scn.containsKey(ir.getId())) { cachedId2scn = cachedListId2scn.get(ir.getId()); LOG.debug("cachedId2scn: " + cachedId2scn); }//from www . ja v a 2 s . c om List<SCNData> thisId2scn = new ArrayList<SCNData>(); List<Field> fields = r.getDataFields(35); for (Field field : fields) { List<String> subfields = SaxMarcXmlRecord.getSubfieldOfField(field, 'a'); for (String subfield : subfields) { String prefix = getPrefix(subfield); if (prefix.equals("")) { // must have a prefix to use as a match point. // TODO MST-503 continue; } SCNData goods = null; try { goods = getMapId(subfield); } catch (Exception e) { continue; } LOG.debug("adding thisId2scn: " + goods); thisId2scn.add(goods); } } LOG.error("gonna compare cachedId2scn: " + cachedId2scn + " ...with... thisId2scn: " + thisId2scn); Set<SCNData> setA = new HashSet<SCNData>(cachedId2scn); Set<SCNData> setB = new HashSet<SCNData>(thisId2scn); boolean same = setA.containsAll(thisId2scn) && setB.containsAll(cachedId2scn); return (!same); }
From source file:gov.nih.nci.sdk.example.generator.CXFSpringConfGenerator.java
public void runProcess() { java.util.Set<String> processedFocusDomainSet = (java.util.Set<String>) getScriptContext().getMemory() .get("processedFocusDomainSet"); if (processedFocusDomainSet == null) { processedFocusDomainSet = new java.util.HashSet<String>(); getScriptContext().getMemory().put("processedFocusDomainSet", processedFocusDomainSet); }//from w ww. j av a2s. co m processedFocusDomainSet.add(getScriptContext().getFocusDomain()); if (processedFocusDomainSet.containsAll(getScriptContext().retrieveDomainSet()) == true) { //All domains have been processed so now we can compile and generate WSDL generateSpringServerConf(); generateSpringClientConf(getScriptContext().getTemplateGroup()); generateSpringWebConf(getScriptContext().getTemplateGroup()); generateBuildScripts(getScriptContext().getTemplateGroup()); } }
From source file:com.nike.cerberus.command.validator.UploadCertFilesPathValidator.java
@Override public void validate(final String name, final Path value) throws ParameterException { if (value == null) { throw new ParameterException("Value must be specified."); }/* www. ja v a 2 s.c o m*/ final File certDirectory = value.toFile(); final Set<String> filenames = Sets.newHashSet(); if (!certDirectory.canRead()) { throw new ParameterException("Specified path is not readable."); } if (!certDirectory.isDirectory()) { throw new ParameterException("Specified path is not a directory."); } final FilenameFilter filter = new RegexFileFilter("^.*\\.pem$"); final File[] files = certDirectory.listFiles(filter); Arrays.stream(files).forEach(file -> filenames.add(file.getName())); if (!filenames.containsAll(EXPECTED_FILE_NAMES)) { final StringJoiner sj = new StringJoiner(", ", "[", "]"); EXPECTED_FILE_NAMES.stream().forEach(sj::add); throw new ParameterException("Not all expected files are present! Expected: " + sj.toString()); } }
From source file:cpd3314.project.CPD3314ProjectTest.java
private void assertYAMLFilesEqual(File a, File b) throws IOException { Yaml yaml1 = new Yaml(); Yaml yaml2 = new Yaml(); FileInputStream aIS = new FileInputStream(a); FileInputStream bIS = new FileInputStream(b); Iterable<Object> aYAML = yaml1.loadAll(aIS); Iterable<Object> bYAML = yaml2.loadAll(bIS); Set<Object> aSet = new HashSet<>(); Set<Object> bSet = new HashSet<>(); for (Object x : aYAML) { aSet.add(x);//from www . j a v a 2s . co m } for (Object y : bYAML) { bSet.add(y); } assertEquals("Files Not Equal Length", aSet.size(), bSet.size()); assertTrue("A does not contain all B", aSet.containsAll(bSet)); assertTrue("B does not contain all A", bSet.containsAll(aSet)); }
From source file:com.hortonworks.streamline.streams.layout.storm.StormTopologyValidator.java
private void validateCustomProcessorLinks() throws ComponentConfigException { List<Map> dataSources = (List) this.topologyConfig.get(TopologyLayoutConstants.JSON_KEY_DATA_SOURCES); Set<String> dataSourceNames = new HashSet<>(); for (Map dataSource : dataSources) { dataSourceNames.add((String) dataSource.get(TopologyLayoutConstants.JSON_KEY_UINAME)); }/*from ww w.j a va 2s .c o m*/ List<Map> processors = (List) this.topologyConfig.get(TopologyLayoutConstants.JSON_KEY_PROCESSORS); Map<String, Schema> inputSchemas = new LinkedHashMap<>(); Map<String, Map<String, Schema>> outputSchemas = new LinkedHashMap<>(); for (Map processor : processors) { String type = (String) processor.get(TopologyLayoutConstants.JSON_KEY_TYPE); if ("CUSTOM".equals(type)) { Map config = (Map) processor.get(TopologyLayoutConstants.JSON_KEY_CONFIG); try { inputSchemas.put((String) processor.get(TopologyLayoutConstants.JSON_KEY_UINAME), getCustomProcessorInputSchema(config)); outputSchemas.put((String) processor.get(TopologyLayoutConstants.JSON_KEY_UINAME), getCustomProcessorOutputSchema(config)); } catch (IOException e) { String message = "Invalid custom processor input or output schema config."; LOG.error(message); throw new ComponentConfigException(message, e); } } } Set<String> customProcessorKeys = outputSchemas.keySet(); List<Map> links = (List) this.topologyConfig.get(TopologyLayoutConstants.JSON_KEY_LINKS); for (Map link : links) { Map linkConfig = (Map) link.get(TopologyLayoutConstants.JSON_KEY_CONFIG); String from = (String) linkConfig.get(TopologyLayoutConstants.JSON_KEY_FROM); String to = (String) linkConfig.get(TopologyLayoutConstants.JSON_KEY_TO); if (customProcessorKeys.contains(from)) { String streamId = (String) linkConfig.get(TopologyLayoutConstants.JSON_KEY_STREAM_ID); if (StringUtils.isEmpty(streamId)) { throw new ComponentConfigException( String.format(TopologyLayoutConstants.ERR_MSG_INVALID_STREAM_ID, link.get(TopologyLayoutConstants.JSON_KEY_UINAME))); } Map<String, Schema> streamIdToOutput = outputSchemas.get(from); Set<String> outputStreams = streamIdToOutput.keySet(); if (!outputStreams.contains(streamId)) { throw new ComponentConfigException( String.format(TopologyLayoutConstants.ERR_MSG_INVALID_STREAM_ID, link.get(TopologyLayoutConstants.JSON_KEY_UINAME))); } if ("FIELDS".equals(link.get(TopologyLayoutConstants.JSON_KEY_TYPE))) { Set<String> outputFields = getTopLevelFieldNamesFromSchema(streamIdToOutput.get(streamId)); List<String> groupingFields = (List) linkConfig .get(TopologyLayoutConstants.JSON_KEY_GROUPING_FIELDS); if (!outputFields.containsAll(groupingFields)) { throw new ComponentConfigException( String.format(TopologyLayoutConstants.ERR_MSG_INVALID_GROUPING_FIELDS, link.get(TopologyLayoutConstants.JSON_KEY_UINAME))); } } } if (customProcessorKeys.contains(to)) { // link to a custom processor can not go from a data source if (dataSourceNames.contains(from)) { throw new ComponentConfigException( String.format(TopologyLayoutConstants.ERR_MSG_INVALID_LINK_TO_PROCESSOR, link.get(TopologyLayoutConstants.JSON_KEY_UINAME))); } } } }
From source file:com.mockey.ui.JsonSchemaValidateServlet.java
@Override public void doPost(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException { final Set<String> params = Sets.newHashSet(); final Enumeration<String> enumeration = req.getParameterNames(); // FIXME: no duplicates, it seems, but I cannot find the spec which // guarantees that while (enumeration.hasMoreElements()) params.add(enumeration.nextElement()); // We have required parameters if (!params.containsAll(ValidateRequest.REQUIRED_PARAMS)) { logger.warn("Missing parameters! Someone using me as a web service?"); resp.sendError(HttpServletResponse.SC_BAD_REQUEST, "Missing parameters"); return;//from w ww. j a v a 2 s. c o m } // We don't want extraneous parameters params.removeAll(ValidateRequest.VALID_PARAMS); if (!params.isEmpty()) { logger.warn("Invalid parameters! Someone using me as a web service?"); resp.sendError(HttpServletResponse.SC_BAD_REQUEST, "Invalid parameters"); return; } final String rawSchema = req.getParameter(ValidateRequest.SCHEMA); final String data = req.getParameter(ValidateRequest.DATA); // Set correct content type resp.setContentType(MediaType.JSON_UTF_8.toString()); final boolean useV3 = Boolean.parseBoolean(req.getParameter(ValidateRequest.USE_V3)); final boolean useId = Boolean.parseBoolean(req.getParameter(ValidateRequest.USE_ID)); final JsonNode ret = JsonSchemaUtil.buildResult(rawSchema, data, useV3, useId); final OutputStream out = resp.getOutputStream(); try { out.write(ret.toString().getBytes(Charset.forName("UTF-8"))); out.flush(); } finally { Closeables.closeQuietly(out); } }
From source file:ome.adapters.pojos.utests.PojosTest.java
@Test public void testNoDuplicateLinks() throws Exception { Project p_2 = new Project(); Dataset d_2 = new Dataset(); Image i_2 = new Image(); p_2.linkDataset(d_2);/* w w w . ja v a2 s.c o m*/ d_2.linkImage(i_2); ProjectData pd = new ProjectData(p_2); DatasetData dd = pd.getDatasets().iterator().next(); Dataset test = (Dataset) dd.asIObject(); Set p_links = new HashSet(p_2.collectDatasetLinks(null)); Set d_links = new HashSet(test.collectProjectLinks(null)); if (log.isDebugEnabled()) { log.debug(p_links); log.debug(d_links); } assertTrue(p_links.containsAll(d_links)); DatasetData dd2 = new DatasetData(test); ImageData id = (ImageData) dd2.getImages().iterator().next(); Image test2 = (Image) id.asIObject(); Set d2_links = new HashSet(d_2.collectImageLinks(null)); Set i2_links = new HashSet(test2.collectDatasetLinks(null)); if (log.isDebugEnabled()) { log.debug(d2_links); log.debug(i2_links); } assertTrue(d2_links.containsAll(i2_links)); }