List of usage examples for java.util Set iterator
Iterator<E> iterator();
From source file:CONTROLLER.TProcessamentoRodada.java
@Override public void run() { ArrayList<String> auxRodada = new ArrayList<>(); Iterator iteratorRodada = jsonArray.iterator(); while (iteratorRodada.hasNext()) { JSONObject objetoRodada = (JSONObject) iteratorRodada.next(); String rodada = (String) objetoRodada.get("round"); auxRodada.add(rodada);/*from www. j a v a2s . c om*/ } Set<String> setRodada = new HashSet<>(); for (String a : auxRodada) { setRodada.add(a); } Iterator<String> iRodada = setRodada.iterator(); int idRodada = 0; while (iRodada.hasNext()) { Rodada auxRodadas = new Rodada(); auxRodadas.setId(idRodada); auxRodadas.setRodada(iRodada.next()); rodadas.add(auxRodadas); idRodada++; } }
From source file:com.softwarecorporativo.monitoriaifpe.funcionais.curso.TesteCurso.java
@Test public void testeCriarCursoComDescricaoInvalida() { Curso curso = montarObjetoCurso();/*from w w w. java2 s . c om*/ String mensagemEsperada = "A descrio do curso deve iniciar com uma letra " + "maiscula seguido de caracteres que no sejam dgitos"; curso.setDescricao("cincia da computao"); Set<ConstraintViolation<Curso>> constraintViolations = validator.validate(curso); String mensagemObtida = constraintViolations.iterator().next().getMessage(); assertEquals(1, constraintViolations.size()); assertEquals(mensagemEsperada, mensagemObtida); }
From source file:de.rrze.idmone.utils.jidgen.filter.FilterChain.java
/** * This method does the actual filtering. It implements the main logic of * the filter./*from ww w . jav a2 s . c o m*/ * * @param id * the id to be checked * @return <em>null</em> if the id should be filtered and the * id if it satisfies the rules. */ public String apply(String id) { Set<String> filterKeys = chain.keySet(); for (Iterator<String> iter = filterKeys.iterator(); iter.hasNext();) { IFilter filter = chain.get(iter.next()); if (filter.apply(id) == null) return null; } return id; }
From source file:com.onpositive.semantic.words3.MultiHashMap.java
public void clear() { Set pairs = super.entrySet(); Iterator pairsIterator = pairs.iterator(); while (pairsIterator.hasNext()) { Map.Entry keyValuePair = (Map.Entry) (pairsIterator.next()); ArrayList list = (ArrayList) (keyValuePair.getValue()); list.clear();//from www .ja v a 2 s . c o m } super.clear(); }
From source file:com.sg.addressbookmvc.dao.AddressBookDaoDbImpl.java
@Override public List<Address> searchAddresses(Map<SearchTerm, String> criteria) { if (criteria == null || criteria.size() == 0) { return getAllAddresses(); }//from w w w . j a v a 2s. com StringBuilder query = new StringBuilder("SELECT * FROM addresses WHERE "); int numParams = criteria.size(); int paramPosition = 0; String[] paramVals = new String[numParams]; Set<SearchTerm> keyset = criteria.keySet(); Iterator<SearchTerm> iter = keyset.iterator(); while (iter.hasNext()) { SearchTerm currentKey = iter.next(); String currentValue = criteria.get(currentKey); if (paramPosition > 0) { query.append(" and "); } query.append(currentKey); query.append(" =? "); paramVals[paramPosition] = currentValue; paramPosition++; } return jdbcTemplate.query(query.toString(), new AddressMapper(), paramVals); }
From source file:me.springframework.di.spring.AliasTest.java
@Test public void aliasesShouldBeTransparentInBeanReferences() { Resource resource = new ClassPathResource("/alias.xml", getClass()); Configuration configuration = readConfiguration(resource); InMemoryDestination dest = new InMemoryDestination("test"); BeanFactoryGenerator.generate(dest, configuration, MINIMAL_JAVA_SE); Instance course = configuration.get("course"); assertEquals(Course.class.getName(), course.getReferencedType()); Set<? extends PropertySetter> setters = course.getSetters(); assertEquals(1, setters.size());//from w ww .jav a 2 s . co m Source source = setters.iterator().next().getSource(); ListSource students = (ListSource) source; MutableInstanceReference s3 = (MutableInstanceReference) students.getElementSources().get(0); assertEquals("defaultStudent", s3.getName()); }
From source file:org.biopax.validator.rules.SameNameDiffKindPhysEntitiesRule.java
public void check(final Validation validation, Model model) { Set<SimplePhysicalEntity> peers = new HashSet<SimplePhysicalEntity>( model.getObjects(SimplePhysicalEntity.class)); Cluster<SimplePhysicalEntity> groupping = new Cluster<SimplePhysicalEntity>() { @Override//from ww w .j a v a 2 s . co m public boolean match(SimplePhysicalEntity a, SimplePhysicalEntity b) { return !a.equals(b) && a.getEntityReference() != null && !a.getName().isEmpty() && !b.getName().isEmpty() && !a.getEntityReference().isEquivalent(b.getEntityReference()) && CollectionUtils.containsAny(a.getName(), b.getName()); } }; Set<Set<SimplePhysicalEntity>> sharedNamesClusters = groupping.cluster(peers, Integer.MAX_VALUE); // report the error once for each cluster for (Set<SimplePhysicalEntity> sharedNames : sharedNamesClusters) { if (sharedNames.size() > 1) { SimplePhysicalEntity a = sharedNames.iterator().next(); error(validation, a, "diff.kind.same.name", false, sharedNames); } } }
From source file:org.eel.kitchen.jsonschema.syntax.AbstractSyntaxCheckerTest.java
@DataProvider public Iterator<Object[]> getData() { final Set<Object[]> set = Sets.newHashSet(); for (final JsonNode node : testData) set.add(mungeArguments(node));//www . j av a2s . c o m return set.iterator(); }
From source file:org.hawkular.apm.api.model.trace.InteractionNode.java
/** * This method determines whether the interaction node is associated with * a multi-consumer communication./*from w ww . j a v a 2 s. c o m*/ * * @return Whether interaction relates to multiple consumers */ public boolean multipleConsumers() { // TODO: When HWKAPM-698 implemented, it may no longer be necessary to capture this info Set<Property> props = getProperties(Producer.PROPERTY_PUBLISH); return !props.isEmpty() && props.iterator().next().getValue().equalsIgnoreCase(Boolean.TRUE.toString()); }