List of usage examples for org.apache.commons.collections IteratorUtils emptyIterator
public static ResettableIterator emptyIterator()
From source file:com.steffi.index.ImgMapIndex.java
@Override public ImgIndexHits<T> get(String key, Object value) { IndexKeyValue indexKeyValue = new IndexKeyValue(key, value); ConcurrentHashMap<Object, Boolean> idElements = getMap().get(indexKeyValue); if (idElements == null || idElements.isEmpty()) return new ImgMapIndexHits<T>(IteratorUtils.emptyIterator(), 0, indexClass); else//from w ww. j av a 2s . c o m return new ImgMapIndexHits<T>(idElements.keySet().iterator(), idElements.size(), indexClass); }
From source file:com.lh.leap.ui.LocationNodeImpl.java
public Enumeration children() { if (children == null) return IteratorUtils.asEnumeration(IteratorUtils.emptyIterator()); return IteratorUtils.asEnumeration(children.iterator()); }
From source file:com.steffi.model.Cell.java
public Iterable<String> getAttributeKeys() { return new Iterable<String>() { @SuppressWarnings("unchecked") @Override/*from w w w .j av a2 s.c o m*/ public Iterator<String> iterator() { if (attributes != null) { final List<String> keys = new ArrayList<String>(); final SteffiGraph graph = SteffiGraph.getInstance(); attributes.forEachKey(new TIntProcedure() { @Override public boolean execute(int keyIndex) { keys.add(graph.getItemName(keyIndex)); return true; } }); return keys.iterator(); } else return IteratorUtils.emptyIterator(); } }; }
From source file:ca.sqlpower.object.annotation.SPAnnotationProcessor.java
@SuppressWarnings("unchecked") @Override/*from w w w.j a v a2s . co m*/ public Iterable<? extends Completion> getCompletions(Element element, AnnotationMirror annotation, ExecutableElement member, String userText) { return (Iterable<? extends Completion>) IteratorUtils.emptyIterator(); }
From source file:hr.fer.zemris.vhdllab.view.explorer.ProjectExplorerView.java
@SuppressWarnings("unchecked") private Iterator<HierarchyNode> getHierarchyIterator(Hierarchy hierarchy, HierarchyNode node) { Integer mode = getHierarchyMode(); switch (mode) { case 0://from ww w . j a v a 2 s . com return hierarchy.iteratorXUsesYHierarchy(node); case 1: return hierarchy.iteratorXUsedByYHierarchy(node); case 2: if (node == null) { return hierarchy.iteratorFlatHierarchy(); } return IteratorUtils.emptyIterator(); default: throw new IllegalStateException(mode.toString()); } }
From source file:org.apache.cayenne.query.SQLTemplate.java
/** * Returns an iterator over parameter sets. Each element returned from the * iterator is a java.util.Map.//www .ja va 2s . c o m */ @SuppressWarnings("unchecked") public Iterator<Map<String, ?>> parametersIterator() { return (parameters == null || parameters.length == 0) ? IteratorUtils.emptyIterator() : IteratorUtils.transformedIterator(IteratorUtils.arrayIterator(parameters), nullMapTransformer); }
From source file:org.apache.sling.resourceresolver.impl.ResourceResolverMangleNamespacesTest.java
@Before public void setup() throws RepositoryException, LoginException { MockitoAnnotations.initMocks(this); activeSession = mockedSession;//from w w w.j a va2s .c o m // Setup a ResourceResolverImpl with namespace mangling and unmangling final ResourceResolverFactoryActivator act = new ResourceResolverFactoryActivator() { @Override public boolean isMangleNamespacePrefixes() { return true; } }; Mockito.when(mockedSession.getNamespacePrefix(NS_PREFIX)).thenReturn(NS_URL); final ResourceProvider<?> rp = new ResourceProvider<Object>() { @SuppressWarnings("unchecked") @Override public @CheckForNull <AdapterType> AdapterType adaptTo(final @Nonnull ResolveContext<Object> ctx, final @Nonnull Class<AdapterType> type) { if (type.equals(Session.class)) { return (AdapterType) activeSession; } else { return null; } } @Override public Resource getResource(ResolveContext<Object> ctx, String path, ResourceContext rCtx, Resource parent) { return null; } @SuppressWarnings("unchecked") @Override public Iterator<Resource> listChildren(ResolveContext<Object> ctx, Resource parent) { return IteratorUtils.emptyIterator(); } }; final CommonResourceResolverFactoryImpl fac = new CommonResourceResolverFactoryImpl(act); rr = new ResourceResolverImpl(fac, false, null, new ResourceProviderStorageProvider() { @Override public ResourceProviderStorage getResourceProviderStorage() { return new ResourceProviderStorage( Arrays.asList(MockedResourceResolverImplTest.createRPHandler(rp, "rp1", 0, "/"))); } }); }
From source file:org.mule.routing.EventGroup.java
/** * Returns an iterator over a snapshot copy of this group's collected events., * optionally sorted by arrival order. If * you need to iterate over the group and e.g. remove select events, do so via * {@link #removeEvent(MuleEvent)}. If you need to do so atomically in order to * prevent e.g. concurrent reception/aggregation of the group during iteration, * wrap the iteration in a synchronized block on the group instance. * * @return an iterator over collected {@link MuleEvent}s. * @throws ObjectStoreException/*from w w w . j av a2 s . c o m*/ */ @SuppressWarnings("unchecked") public Iterator<MuleEvent> iterator(boolean sortByArrival) throws ObjectStoreException { synchronized (events) { if (events.allKeys().isEmpty()) { return IteratorUtils.emptyIterator(); } else { return IteratorUtils.arrayIterator(this.toArray(sortByArrival)); } } }
From source file:org.objectstyle.cayenne.query.SQLTemplate.java
/** * Returns an iterator over parameter sets. Each element returned from the iterator is * a java.util.Map./*www . j a v a 2 s. c om*/ */ public Iterator parametersIterator() { return (parameters == null || parameters.length == 0) ? IteratorUtils.emptyIterator() : IteratorUtils.transformedIterator(IteratorUtils.arrayIterator(parameters), nullMapTransformer); }
From source file:org.openmrs.module.amrsreports.reporting.data.evaluator.RegimenHistoryDataEvaluator.java
/** * Finds a history of regimens and reasons for change for each person in a cohort * * @param definition the RegimenHistoryDataDefinition to be evaluated * @param context the evaluation context for a given report * @return an ordered list of RegimenChange objects for each person * @throws EvaluationException/*from w w w. j a va 2s . c o m*/ * @should find a regimen if it exists * @should return nothing if DrugSnapshots do not indicate a Regimen * @should only return a reason from the same encounter as the DrugSnapshot used to indicate a Regimen */ @Override public EvaluatedPersonData evaluate(PersonDataDefinition definition, EvaluationContext context) throws EvaluationException { EvaluatedPersonData c = new EvaluatedPersonData(definition, context); if (context.getBaseCohort().isEmpty()) return c; // get drug snapshots SortedSetMap<Integer, DrugSnapshot> snapshots = MOHReportUtil .getARVSnapshotsMapFromTables(context.getBaseCohort(), context.getEvaluationDate()); // get relevant reason observations SortedSetMap<Integer, Obs> reasons = getReasons(context); // get birthdates EvaluatedPersonData birthDateData = Context.getService(PersonDataService.class) .evaluate(new BirthdateDataDefinition(), context); Map<Integer, Object> birthDates = birthDateData.getData(); // build the regimen history for (Integer pId : snapshots.keySet()) { if (snapshots.get(pId) != null) { // find the birthdate Birthdate birthDate = null; if (birthDates.containsKey(pId)) { birthDate = (Birthdate) birthDates.get(pId); } // get iterators for snapshots and reasons Iterator<DrugSnapshot> dsI = snapshots.get(pId).iterator(); Iterator<Obs> oI = reasons.containsKey(pId) ? reasons.get(pId).iterator() : IteratorUtils.emptyIterator(); Regimen lastRegimen = null; // crawl through snapshots List<RegimenChange> res = new ArrayList<RegimenChange>(); while (dsI.hasNext()) { DrugSnapshot ds = dsI.next(); if (ds != null) { // get the current ageRange for this snapshot String ageRange = getAgeRange(birthDate, ds.getDateTaken()); // figure out what regimens belong in this snapshot List<Regimen> regimens = findPotentialRegimens(ds, ageRange); // use the first regimen in the list if (regimens != null && !regimens.isEmpty()) { if (regimens.size() > 1) { log.warn("Multiple regimens match " + ds + ", using " + regimens.get(0)); } Regimen thisRegimen = regimens.get(0); // only add a RegimenChange if thisRegimen is different from the last one if (lastRegimen == null || !OpenmrsUtil.nullSafeEquals(thisRegimen.getName(), lastRegimen.getName())) { // update lastRegimen lastRegimen = thisRegimen; // fill out a change if this snapshot has regimens RegimenChange rc = new RegimenChange(); rc.setRegimen(thisRegimen); rc.setDateOccurred(ds.getDateTaken()); // find the reason boolean found = false; while (oI.hasNext() && !found) { Obs o = oI.next(); // if the snapshot and reason come from the same encounter, we have a winner if (OpenmrsUtil.nullSafeEquals(o.getEncounter().getId(), ds.getEncounter().getId())) { rc.setReason(o.getValueCoded().getDisplayString()); found = true; } } // whether the reason was found or not, add the change res.add(rc); } } } } c.addData(pId, res); } } return c; }