List of usage examples for com.google.common.collect Multimap isEmpty
boolean isEmpty();
From source file:com.b2international.snowowl.datastore.server.oplock.impl.RemoteLockTargetListener.java
@Override protected void onLogout(final IApplicationSessionManager manager, final RpcSession session) { if (null == session) { return;//from w w w. ja v a2 s. c o m } if (!remotelyLockedContexts.containsKey(session)) { return; } final Multimap<IOperationLockTarget, DatastoreLockContext> targetsForSession = remotelyLockedContexts .remove(session); if (targetsForSession.isEmpty()) { return; } final String disconnectedUserId = (String) session.get(IApplicationSessionManager.KEY_USER_ID); if (null == disconnectedUserId) { return; } LOGGER.warn("Disconnected client had locks granted, unlocking."); final IDatastoreOperationLockManager lockManager = ApplicationContext.getInstance() .getServiceChecked(IDatastoreOperationLockManager.class); for (final Entry<IOperationLockTarget, DatastoreLockContext> targetContextPair : targetsForSession .entries()) { try { lockManager.unlock(targetContextPair.getValue(), targetContextPair.getKey()); } catch (final OperationLockException e) { LOGGER.error("Failed to unlock targets left after closed session.", e); } } }
From source file:com.palantir.atlasdb.keyvalue.impl.ValidatingQueryRewritingKeyValueService.java
@Override public void delete(String tableName, Multimap<Cell, Long> keys) { if (keys.isEmpty()) { return;/*from w ww. jav a 2 s . co m*/ } delegate.delete(tableName, keys); }
From source file:fr.ujm.tse.lt2c.satin.rules.run.RunRHODF6d.java
@Override protected int process(final TripleStore ts1, final TripleStore ts2, final Collection<Triple> outputTriples) { final long domain = AbstractDictionary.domain; final long range = AbstractDictionary.range; final long subPropertyOf = AbstractDictionary.subPropertyOf; int loops = 0; final Multimap<Long, Long> domainMultiMap = ts2.getMultiMapForPredicate(domain); final Multimap<Long, Long> rangeMultiMap = ts2.getMultiMapForPredicate(range); if (domainMultiMap != null && !domainMultiMap.isEmpty()) { for (final Long s : domainMultiMap.keySet()) { loops++;/*from w w w . j a v a 2 s.c o m*/ final Triple result = new ImmutableTriple(s, subPropertyOf, s); outputTriples.add(result); } } if (rangeMultiMap != null && !rangeMultiMap.isEmpty()) { for (final Long s : rangeMultiMap.keySet()) { loops++; final Triple result = new ImmutableTriple(s, subPropertyOf, s); outputTriples.add(result); } } return loops; }
From source file:model.utilities.dummies.GeographicalCustomer.java
/** * Chooses which of this firms the customer wants to choose, if any. * @param firmsToChooseFrom The list of available firms * @return The firm chosen, or null if none is chosen */// ww w .j a v a2 s .c o m public GeographicalFirm chooseSupplier(final Multimap<GeographicalFirm, Quote> firmsToChooseFrom) { Preconditions.checkArgument(!firmsToChooseFrom.isEmpty()); handleNewEvent( new LogEvent(this, LogLevel.TRACE, "was given these firms to choose from: {}", firmsToChooseFrom)); //basically we want to find the minimum price+distance GeographicalFirm best = Collections.min(firmsToChooseFrom.keySet(), new Comparator<GeographicalFirm>() { @Override public int compare(GeographicalFirm o1, GeographicalFirm o2) { //price + distance double pricePlusDistance1 = firmsToChooseFrom.get(o1).iterator().next().getPriceQuoted() + distance(GeographicalCustomer.this, o1); assert pricePlusDistance1 >= 0; double pricePlusDistance2 = firmsToChooseFrom.get(o2).iterator().next().getPriceQuoted() + distance(GeographicalCustomer.this, o2); assert pricePlusDistance2 >= 0; return Double.compare(pricePlusDistance1, pricePlusDistance2); } }); assert best != null; //is the minimum price distance okay? final long bestPriceAtSource = firmsToChooseFrom.get(best).iterator().next().getPriceQuoted(); double bestPricePlusDistance = bestPriceAtSource + distance(GeographicalCustomer.this, best); //log it! handleNewEvent( new LogEvent(this, LogLevel.TRACE, "the best firm found was {}, pricing {}, total personal cost {}", best, bestPriceAtSource, bestPricePlusDistance)); if (bestPricePlusDistance <= getMaxPrice()) { handleNewEvent(new LogEvent(this, LogLevel.TRACE, "decided to buy from chosen best")); return best; } else return null; }
From source file:de.metas.ui.web.window.descriptor.DocumentFieldDependencyMap.java
public void consumeForChangedFieldName(final String changedFieldName, final IDependencyConsumer consumer) { for (final DependencyType dependencyType : DependencyType.values()) { final Multimap<String, String> name2dependencies = type2name2dependencies.get(dependencyType); if (name2dependencies == null || name2dependencies.isEmpty()) { continue; }/*w w w . j a v a 2 s . co m*/ for (final String dependentFieldName : name2dependencies.get(changedFieldName)) { consumer.consume(dependentFieldName, dependencyType); } } }
From source file:com.ardor3d.util.TextureManager.java
/** * Delete all textures from card. This will gather all texture ids believed to be on the card and try to delete * them. If a deleter is passed in, textures that are part of the currently active context (if one is active) will * be deleted immediately. If a deleter is not passed in, we do not have an active context, or we encounter textures * that are not part of the current context, then we will queue those textures to be deleted later using the * GameTaskQueueManager.//w ww . j av a 2s .co m * * If a non null map is passed into futureStore, it will be populated with Future objects for each queued context. * These objects may be used to discover when the deletion tasks have all completed. * * @param deleter * if not null, this renderer will be used to immediately delete any textures in the currently active * context. All other textures will be queued to delete in their own contexts. * @param futureStore * if not null, this map will be populated with any Future task handles created during cleanup. */ public static void cleanAllTextures(final Renderer deleter, final Map<Object, Future<Void>> futureStore) { // gather up expired textures... these don't exist in our cache Multimap<Object, Integer> idMap = gatherGCdIds(); // Walk through the cached items and gather those too. for (final TextureKey key : _tCache.keySet()) { // possibly lazy init if (idMap == null) { idMap = ArrayListMultimap.create(); } if (Constants.useMultipleContexts) { final Set<Object> contextObjects = key.getContextObjects(); for (final Object o : contextObjects) { // Add id to map idMap.put(o, key.getTextureIdForContext(o)); } } else { idMap.put(ContextManager.getCurrentContext().getGlContextRep(), key.getTextureIdForContext(null)); } key.removeFromIdCache(); } // delete the ids if (idMap != null && !idMap.isEmpty()) { handleTextureDelete(deleter, idMap, futureStore); } }
From source file:net.shibboleth.idp.saml.metadata.impl.AttributeMappingNodeProcessor.java
/** * Look inside the {@link AttributeConsumingService} for any {@link RequestedAttribute}s and map them. * /*w w w . j av a2s .c o m*/ * @param acs the {@link AttributeConsumingService} to look at */ private void handleAttributeConsumingService(AttributeConsumingService acs) { final List<RequestedAttribute> requestedAttributes = acs.getRequestAttributes(); final RequestedAttributesMapper mapper = getRequestedAttributesMapper(); if (null == requestedAttributes || requestedAttributes.isEmpty() || null == mapper) { return; } final Multimap<String, IdPRequestedAttribute> maps = mapper.mapAttributes(requestedAttributes); if (null == maps || maps.isEmpty()) { return; } acs.getObjectMetadata().put(new AttributesMapContainer<>(maps)); }
From source file:net.shibboleth.idp.saml.metadata.impl.AttributeMappingNodeProcessor.java
/** * Look inside the {@link EntityDescriptor} for entities Attributes and map them. * /* www .j av a 2s. c om*/ * @param entity the entity */ private void handleEntityDescriptor(EntityDescriptor entity) { final SAML2AttributesMapper mapper = getAttributesMapper(); final Extensions extensions = entity.getExtensions(); if (null == extensions || null == mapper) { return; } final List<XMLObject> entityAttributesList = extensions .getUnknownXMLObjects(EntityAttributes.DEFAULT_ELEMENT_NAME); if (null == entityAttributesList || entityAttributesList.isEmpty()) { return; } final List<Attribute> entityAttributes = new ArrayList<>(); for (XMLObject xmlObj : entityAttributesList) { if (xmlObj instanceof EntityAttributes) { EntityAttributes ea = (EntityAttributes) xmlObj; entityAttributes.addAll(ea.getAttributes()); } } final Multimap<String, IdPAttribute> maps = mapper.mapAttributes(entityAttributes); if (null == maps || maps.isEmpty()) { return; } entity.getObjectMetadata().put(new AttributesMapContainer<>(maps)); }
From source file:com.haulmont.timesheets.global.WeeklyReportConverter.java
public List<WeeklyReportEntry> convertFromTimeEntries(List<TimeEntry> timeEntries) { if (timeEntries.isEmpty()) { return Collections.emptyList(); }// w ww . jav a 2 s.c o m final Multimap<TimeEntryGroupKey, TimeEntry> groupedTimeEntries = ArrayListMultimap.create(); for (TimeEntry timeEntry : timeEntries) { groupedTimeEntries.put(new TimeEntryGroupKey(timeEntry), timeEntry); } if (groupedTimeEntries.isEmpty()) { return Collections.emptyList(); } List<WeeklyReportEntry> reportEntries = new ArrayList<>(); for (Map.Entry<TimeEntryGroupKey, Collection<TimeEntry>> entry : groupedTimeEntries.asMap().entrySet()) { WeeklyReportEntry reportEntry = new WeeklyReportEntry(); TimeEntryGroupKey entryKey = entry.getKey(); reportEntry.setProject(entryKey.project); reportEntry.setTask(entryKey.task); reportEntry.setActivityType(entryKey.activityType); for (TimeEntry timeEntry : entry.getValue()) { reportEntry.addTimeEntry(timeEntry); } reportEntries.add(reportEntry); } return reportEntries; }
From source file:com.palantir.atlasdb.sweep.SweepTaskRunner.java
private void sweepCells(String tableName, Multimap<Cell, Long> cellTsPairsToSweep, Set<Cell> sentinelsToAdd) { if (cellTsPairsToSweep.isEmpty()) { return;/*from ww w . j a va2 s .com*/ } for (Follower follower : followers) { follower.run(txManager, tableName, cellTsPairsToSweep.keySet(), TransactionType.HARD_DELETE); } if (!sentinelsToAdd.isEmpty()) { keyValueService.addGarbageCollectionSentinelValues(tableName, sentinelsToAdd); } keyValueService.delete(tableName, cellTsPairsToSweep); }