List of usage examples for java.util SortedSet iterator
Iterator<E> iterator();
From source file:com.smhdemo.common.datasource.generate.factory.init.bean.BeanForInterfaceFactory.java
@SuppressWarnings({ "rawtypes", "unchecked" }) @Override//from w w w . j a v a 2 s .com public String getBeanName(Map interfaceToBeanMappings, Class itfClass) { if (interfaceToBeanMappings == null) { return null; } try { SortedSet interfaces = new TreeSet(itfComparator); for (Iterator it = interfaceToBeanMappings.keySet().iterator(); it.hasNext();) { String itfName = (String) it.next(); Class itf = Class.forName(itfName, true, Thread.currentThread().getContextClassLoader()); if (itf.isAssignableFrom(itfClass)) { interfaces.add(itf); } } if (!interfaces.isEmpty()) { Class itf = (Class) interfaces.iterator().next(); return (String) interfaceToBeanMappings.get(itf.getName()); } return null; } catch (ClassNotFoundException e) { logger.error("ClassNotFoundException", e); throw new BaseRuntimeExceptionWrapper(e); } }
From source file:com.spotify.heroic.filter.impl.OrFilterImpl.java
private static Filter optimize(SortedSet<Filter> statements) { final SortedSet<Filter> result = new TreeSet<>(); root: for (final Filter f : statements) { if (f instanceof Filter.Not) { final Filter.Not not = (Filter.Not) f; if (statements.contains(not.first())) { return TrueFilterImpl.get(); }/*from w w w.j a va2s .c om*/ result.add(f); continue; } if (f instanceof Filter.StartsWith) { final Filter.StartsWith outer = (Filter.StartsWith) f; for (final Filter inner : statements) { if (inner.equals(outer)) { continue; } if (inner instanceof Filter.StartsWith) { final Filter.StartsWith starts = (Filter.StartsWith) inner; if (!outer.first().equals(starts.first())) { continue; } if (FilterComparatorUtils.prefixedWith(outer.second(), starts.second())) { continue root; } } } result.add(f); continue; } // all ok! result.add(f); } if (result.isEmpty()) { return TrueFilterImpl.get(); } if (result.size() == 1) { return result.iterator().next(); } return new OrFilterImpl(new ArrayList<>(result)); }
From source file:com.jaspersoft.jasperserver.api.common.service.impl.BeanForInterfaceFactoryImpl.java
public String getBeanName(Map interfaceToBeanMappings, Class itfClass) { if (interfaceToBeanMappings == null) { return null; }//from w ww. j a v a2s . c om //TODO cache try { SortedSet interfaces = new TreeSet(itfComparator); for (Iterator it = interfaceToBeanMappings.keySet().iterator(); it.hasNext();) { String itfName = (String) it.next(); Class itf = Class.forName(itfName, true, Thread.currentThread().getContextClassLoader()); if (itf.isAssignableFrom(itfClass)) { interfaces.add(itf); } } if (!interfaces.isEmpty()) { Class itf = (Class) interfaces.iterator().next(); return (String) interfaceToBeanMappings.get(itf.getName()); } return null; } catch (ClassNotFoundException e) { log.error(e, e); throw new JSExceptionWrapper(e); } }
From source file:com.restfb.util.InsightUtilsTest.java
@Test public void convertToMidnightInPacificTimeZoneSet1() throws ParseException { Date d20030630_0221utc = sdfUTC.parse("20030630_0221"); Date d20030629_0000pst = sdfPST.parse("20030629_0000"); Date d20030630_1503utc = sdfUTC.parse("20030630_1503"); Date d20030630_0000pst = sdfPST.parse("20030630_0000"); Set<Date> inputs = new HashSet<Date>(); inputs.add(d20030630_0221utc);// w w w . jav a 2 s . c o m inputs.add(d20030630_1503utc); SortedSet<Date> actuals = convertToMidnightInPacificTimeZone(inputs); assertEquals(2, actuals.size()); Iterator<Date> it = actuals.iterator(); assertEquals(d20030629_0000pst, it.next()); assertEquals(d20030630_0000pst, it.next()); }
From source file:net.sourceforge.fenixedu.presentationTier.backBeans.person.OrganizationalStructureBackingBean.java
private SortedSet<Function> getSortFunctionList(Unit unit) { SortedSet<Function> functions = unit.getOrderedFunctions(); Iterator<Function> iterator = functions.iterator(); while (iterator.hasNext()) { Function function = iterator.next(); if (function.isVirtual()) { iterator.remove();//from ww w . j a v a 2 s . com } } return functions; }
From source file:de.berlios.statcvs.xml.output.ReportSettings.java
public List getModules(CvsContent content) { LinkedList modules = new LinkedList(); Object o = get("modules", null); if (o instanceof Map) { Map map = (Map) o; for (Iterator it = map.keySet().iterator(); it.hasNext();) { Object key = it.next(); modules.add(new Module(key.toString(), map.get(key).toString())); }// ww w . j a v a 2s . c o m } else { SortedSet directories = content.getDirectories(); for (Iterator it = directories.iterator(); it.hasNext();) { Directory dir = (Directory) it.next(); if (!dir.isRoot()) { modules.add(new Module(dir)); } } } return modules; }
From source file:org.mitre.mpf.wfm.data.entities.transients.Track.java
protected int compareDetections(SortedSet<Detection> a, SortedSet<Detection> b) { if (a == null && b == null) { return 0; } else if (a == null) { return 1; } else if (b == null) { return -1; } else {/*from w w w .j ava 2 s . c om*/ int comparisonResult = 0; comparisonResult = Integer.compare(a.size(), b.size()); Iterator<Detection> firstIterator = a.iterator(); Iterator<Detection> secondIterator = b.iterator(); while ((comparisonResult == 0 && firstIterator.hasNext() && secondIterator.hasNext())) { Detection first = firstIterator.next(); Detection second = secondIterator.next(); if (first == null && second == null) { comparisonResult = 0; } else if (first == null) { comparisonResult = -1; // null < non-null } else if (second == null) { comparisonResult = 1; } else { comparisonResult = first.compareTo(second); } } return comparisonResult; } }
From source file:pt.ist.fenix.ui.faces.bean.person.OrganizationalStructureBackingBean.java
private SortedSet<Function> getSortFunctionList(Unit unit) { SortedSet<Function> functions = Function.getOrderedFunctions(unit); Iterator<Function> iterator = functions.iterator(); while (iterator.hasNext()) { Function function = iterator.next(); if (function.isVirtual()) { iterator.remove();/*from w ww. j a va 2 s . c o m*/ } } return functions; }
From source file:hku.fyp14017.blencode.ui.controller.SoundController.java
public void deleteCheckedSounds(Activity activity, SoundBaseAdapter adapter, ArrayList<SoundInfo> soundInfoList, MediaPlayer mediaPlayer) {//w w w .ja v a 2 s .c om SortedSet<Integer> checkedSounds = adapter.getCheckedItems(); Iterator<Integer> iterator = checkedSounds.iterator(); SoundController.getInstance().stopSoundAndUpdateList(mediaPlayer, soundInfoList, adapter); int numberDeleted = 0; while (iterator.hasNext()) { int position = iterator.next(); deleteSound(position - numberDeleted, soundInfoList, activity); ++numberDeleted; } }
From source file:org.sonar.java.se.JavaCheckVerifier.java
private void validateFlowAttributes(List<AnalyzerMessage> actual, String flowId) { SortedSet<Expectations.FlowComment> expected = expectations.flows.get(flowId); validateFlowMessages(actual, flowId, expected); Iterator<AnalyzerMessage> actualIterator = actual.iterator(); Iterator<Expectations.FlowComment> expectedIterator = expected.iterator(); while (actualIterator.hasNext() && expectedIterator.hasNext()) { AnalyzerMessage.TextSpan flowLocation = actualIterator.next().primaryLocation(); assertThat(flowLocation).isNotNull(); Expectations.FlowComment flowComment = expectedIterator.next(); validateLocation(flowComment.attributes, flowLocation); }/* w w w .ja v a 2 s. c o m*/ }