com.google.common.collect.Multimap#containsEntry ( )源码实例Demo

下面列出了com.google.common.collect.Multimap#containsEntry ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: javaide   文件: ViewTypeDetector.java
private static void addViewTags(Multimap<String, String> map, Element element) {
    String id = element.getAttributeNS(ANDROID_URI, ATTR_ID);
    if (id != null && !id.isEmpty()) {
        id = LintUtils.stripIdPrefix(id);
        if (!map.containsEntry(id, element.getTagName())) {
            map.put(id, element.getTagName());
        }
    }

    NodeList children = element.getChildNodes();
    for (int i = 0, n = children.getLength(); i < n; i++) {
        Node child = children.item(i);
        if (child.getNodeType() == Node.ELEMENT_NODE) {
            addViewTags(map, (Element) child);
        }
    }
}
 
@Override
public ListenableFuture<Void> onParticipantAdded(WaveletName waveletName, ParticipantId user) {
  Multimap<WaveId, WaveletId> perUserView = explicitPerUserWaveViews.getIfPresent(user);
  if (perUserView != null) {
    if (!perUserView.containsEntry(waveletName.waveId, waveletName.waveletId)) {
      perUserView.put(waveletName.waveId, waveletName.waveletId);
      if(LOG.isFineLoggable()) {
        LOG.fine("Added wavelet: " + waveletName + " to the view of user: " + user.getAddress());
        LOG.fine("View size is now: " + perUserView.size());
      }
    }
  }
  SettableFuture<Void> task = SettableFuture.create();
  task.set(null);
  return task;
}
 
@Override
public ListenableFuture<Void> onParticipantAdded(WaveletName waveletName, ParticipantId user) {
  Multimap<WaveId, WaveletId> perUserView = explicitPerUserWaveViews.getIfPresent(user);
  if (perUserView != null) {
    if (!perUserView.containsEntry(waveletName.waveId, waveletName.waveletId)) {
      perUserView.put(waveletName.waveId, waveletName.waveletId);
      if(LOG.isFineLoggable()) {
        LOG.fine("Added wavelet: " + waveletName + " to the view of user: " + user.getAddress());
        LOG.fine("View size is now: " + perUserView.size());
      }
    }
  }
  SettableFuture<Void> task = SettableFuture.create();
  task.set(null);
  return task;
}
 
源代码4 项目: datawave   文件: ExpandCompositeTerms.java
/**
 * Attempts to create composites using both the leaf nodes and the anded nodes from our ancestors. Each of the composites created must contain at least one
 * of the leaf nodes in order to be valid. The used leaf nodes are passed back via the usedLeafNodes param. The used anded nodes are passed back via the
 * parentData.
 *
 * @param parentData
 *            Contains the ancestor anded nodes, anded nodes used to create the returned composites, and a flag indicating whether composites were found
 * @param nonLeafNodes
 *            A collection of non-leaf child nodes, from the parent node
 * @param leafNodes
 *            A multimap of leaf child nodes, keyed by field name, from the parent node
 * @param usedLeafNodes
 *            A multimap of used leaf child nodes, keyed by field name, used to create the returned composites
 * @return A list of modified and unmodified non-leaf child nodes, from the parent node
 */
private List<JexlNode> processNonLeafNodes(ExpandData parentData, Collection<JexlNode> nonLeafNodes, Multimap<String,JexlNode> leafNodes,
                Multimap<String,JexlNode> usedLeafNodes) {
    // descend into the child nodes, passing the anded leaf nodes down,
    // in order to determine whether or not composites can be made
    List<JexlNode> unmodifiedNodes = new ArrayList<>();
    List<JexlNode> modifiedNodes = new ArrayList<>();
    for (JexlNode nonLeafNode : nonLeafNodes) {
        ExpandData eData = new ExpandData();
        
        // add the anded leaf nodes from our ancestors
        eData.andedNodes.putAll(parentData.andedNodes);
        
        // add our anded leaf nodes
        eData.andedNodes.putAll(leafNodes);
        
        // descend into the non-leaf node to see if composites can be made
        JexlNode processedNode = (JexlNode) nonLeafNode.jjtAccept(this, eData);
        
        // if composites were made, save the processed node, and determine which leaf
        // nodes were used from this and node (if any)
        if (eData.foundComposite) {
            parentData.foundComposite = true;
            modifiedNodes.add(processedNode);
            for (Entry<String,JexlNode> usedAndedNode : eData.usedAndedNodes.entries())
                if (leafNodes.containsEntry(usedAndedNode.getKey(), usedAndedNode.getValue()))
                    usedLeafNodes.put(usedAndedNode.getKey(), usedAndedNode.getValue());
                else
                    parentData.usedAndedNodes.put(usedAndedNode.getKey(), usedAndedNode.getValue());
        } else
            unmodifiedNodes.add(nonLeafNode);
    }
    
    // add unmodified nodes, then modified nodes
    List<JexlNode> processedNodes = new ArrayList<>();
    processedNodes.addAll(unmodifiedNodes);
    processedNodes.addAll(modifiedNodes);
    
    return processedNodes;
}
 
源代码5 项目: bundletool   文件: ModuleDependencyValidator.java
/** Checks that a module doesn't depend on itself. */
private static void checkNoReflexiveDependencies(Multimap<String, String> moduleDependenciesMap) {
  for (String moduleName : moduleDependenciesMap.keySet()) {
    // The base module is the only one that will have a self-loop in the dependencies map.
    if (!moduleName.equals(BASE_MODULE_NAME.getName())) {
      if (moduleDependenciesMap.containsEntry(moduleName, moduleName)) {
        throw InvalidBundleException.builder()
            .withUserMessage("Module '%s' depends on itself via <uses-split>.", moduleName)
            .build();
      }
    }
  }
}
 
源代码6 项目: bundletool   文件: ModuleDependenciesUtils.java
/**
 * Builds a map of module dependencies.
 *
 * <p>If module "a" contains {@code <uses-split name="b"/>} manifest entry, then the map contains
 * entry ("a", "b").
 *
 * <p>All modules implicitly depend on the "base" module. Hence the map contains also dependency
 * ("base", "base").
 */
public static Multimap<String, String> buildAdjacencyMap(ImmutableList<BundleModule> modules) {
  Multimap<String, String> moduleDependenciesMap = ArrayListMultimap.create();

  for (BundleModule module : modules) {
    String moduleName = module.getName().getName();
    AndroidManifest manifest = module.getAndroidManifest();

    checkArgument(
        !moduleDependenciesMap.containsKey(moduleName),
        "Module named '%s' was passed in multiple times.",
        moduleName);

    moduleDependenciesMap.putAll(moduleName, manifest.getUsesSplits());

    // Check that module does not declare explicit dependency on the "base" module
    // (whose split ID actually is empty instead of "base" anyway).
    if (moduleDependenciesMap.containsEntry(moduleName, BASE_MODULE_NAME.getName())) {
      throw InvalidBundleException.builder()
          .withUserMessage(
              "Module '%s' declares dependency on the '%s' module, which is implicit.",
              moduleName, BASE_MODULE_NAME)
          .build();
    }

    // Add implicit dependency on the base. Also ensures that every module has a key in the map.
    moduleDependenciesMap.put(moduleName, BASE_MODULE_NAME.getName());
  }

  return Multimaps.unmodifiableMultimap(moduleDependenciesMap);
}
 
源代码7 项目: NullAway   文件: NullAway.java
/**
 * @param fieldSymbol the field
 * @param initTreePath TreePath to the initializer method / block
 * @param state visitor state
 * @return true if the field is always initialized (by some other initializer) before the
 *     initializer corresponding to initTreePath executes
 */
private boolean fieldInitializedByPreviousInitializer(
    Symbol fieldSymbol, TreePath initTreePath, VisitorState state) {
  TreePath enclosingClassPath = initTreePath.getParentPath();
  ClassTree enclosingClass = (ClassTree) enclosingClassPath.getLeaf();
  Multimap<Tree, Element> tree2Init =
      initTree2PrevFieldInit.get(ASTHelpers.getSymbol(enclosingClass));
  if (tree2Init == null) {
    tree2Init = computeTree2Init(enclosingClassPath, state);
    initTree2PrevFieldInit.put(ASTHelpers.getSymbol(enclosingClass), tree2Init);
  }
  return tree2Init.containsEntry(initTreePath.getLeaf(), fieldSymbol);
}
 
源代码8 项目: cuba   文件: PersistenceSecurityImpl.java
@SuppressWarnings("unchecked")
protected void applyConstraints(Entity entity, Set<EntityId> handled) {
    MetaClass metaClass = entity.getMetaClass();
    EntityId entityId = new EntityId(referenceToEntitySupport.getReferenceId(entity), metaClass.getName());
    if (handled.contains(entityId)) {
        return;
    }
    handled.add(entityId);
    if (entity instanceof BaseGenericIdEntity) {
        BaseGenericIdEntity baseGenericIdEntity = (BaseGenericIdEntity) entity;
        Multimap<String, Object> filteredData = BaseEntityInternalAccess.getFilteredData(baseGenericIdEntity);
        for (MetaProperty property : metaClass.getProperties()) {
            if (metadataTools.isPersistent(property) && PersistenceHelper.isLoaded(entity, property.getName())) {
                Object value = entity.getValue(property.getName());
                if (value instanceof Collection) {
                    Collection entities = (Collection) value;
                    for (Iterator<Entity> iterator = entities.iterator(); iterator.hasNext(); ) {
                        Entity item = iterator.next();
                        if (filteredData != null && filteredData.containsEntry(property.getName(),
                                referenceToEntitySupport.getReferenceId(item))) {
                            iterator.remove();
                        } else {
                            applyConstraints(item, handled);
                        }
                    }
                } else if (value instanceof Entity) {
                    if (filteredData != null && filteredData.containsEntry(property.getName(),
                            referenceToEntitySupport.getReferenceId((Entity) value))) {
                        baseGenericIdEntity.setValue(property.getName(), null);
                    } else {
                        applyConstraints((Entity) value, handled);
                    }
                }
            }
        }
    }
}
 
源代码9 项目: spotbugs   文件: Guava.java
@ExpectWarning(value="GC", num=7)
public static void testMultimap(Multimap<String, Integer> mm) {
    mm.containsEntry("x", "y");
    mm.containsEntry(1, 5);
    mm.containsKey(1);
    mm.containsValue("x");
    mm.remove("x", "x");
    mm.remove(1, 2);
    mm.removeAll(1);
}
 
源代码10 项目: spotbugs   文件: Guava.java
@NoWarning("GC")
public static void testMultimapOK(Multimap<String, Integer> mm) {
    mm.containsEntry("x", 1);
    mm.containsKey("x");
    mm.containsValue(1);
    mm.remove("x", 1);
    mm.removeAll("x");
}
 
源代码11 项目: spotbugs   文件: Guava.java
@NoWarning("GC")
public static void testMultimapOK2(Multimap<String, Pair<Integer,Long>> mm) {
    Pair<Integer, Long> p = new Pair<Integer, Long>(1, 1L);
    mm.containsEntry("x", p);
    mm.containsKey("x");
    mm.containsValue(p);
    mm.remove("x", p);
    mm.removeAll("x");
}
 
源代码12 项目: swellrt   文件: MemoryPerUserWaveViewHandlerImpl.java
@Override
public ListenableFuture<Void> onParticipantRemoved(WaveletName waveletName, ParticipantId user) {
  Multimap<WaveId, WaveletId> perUserView = explicitPerUserWaveViews.getIfPresent(user);
  if (perUserView != null) {
    if (perUserView.containsEntry(waveletName.waveId, waveletName.waveletId)) {
      perUserView.remove(waveletName.waveId, waveletName.waveletId);
      LOG.fine("Removed wavelet: " + waveletName
          + " from the view of user: " + user.getAddress());
    }
  }
  SettableFuture<Void> task = SettableFuture.create();
  task.set(null);
  return task;
}
 
@Override
public ListenableFuture<Void> onParticipantRemoved(WaveletName waveletName, ParticipantId user) {
  Multimap<WaveId, WaveletId> perUserView = explicitPerUserWaveViews.getIfPresent(user);
  if (perUserView != null) {
    if (perUserView.containsEntry(waveletName.waveId, waveletName.waveletId)) {
      perUserView.remove(waveletName.waveId, waveletName.waveletId);
      LOG.fine("Removed wavelet: " + waveletName
          + " from the view of user: " + user.getAddress());
    }
  }
  SettableFuture<Void> task = SettableFuture.create();
  task.set(null);
  return task;
}
 
源代码14 项目: twill   文件: YarnTwillRunnerService.java
/**
 * Creates a {@link Runnable} for renewing {@link SecureStore} for running applications.
 *
 * @param scheduler the schedule to schedule next renewal execution
 * @param renewer the {@link SecureStoreRenewer} to use for renewal
 * @param retryRuns if non-empty, only the given set of application name and run id that need to have
 *                  secure store renewed; if empty, renew all running applications
 * @param retryDelay the delay before retrying applications that are failed to have secure store renewed
 * @param timeUnit the unit for the {@code delay} and {@code failureDelay}.
 * @return a {@link Runnable}
 */
private Runnable createSecureStoreUpdateRunnable(final ScheduledExecutorService scheduler,
                                                 final SecureStoreRenewer renewer,
                                                 final Multimap<String, RunId> retryRuns,
                                                 final long retryDelay, final TimeUnit timeUnit) {
  return new Runnable() {
    @Override
    public void run() {
      // Collects the set of running application runs
      Table<String, RunId, YarnTwillController> liveApps;

      synchronized (YarnTwillRunnerService.this) {
        if (retryRuns.isEmpty()) {
          liveApps = HashBasedTable.create(controllers);
        } else {
          // If this is a renew retry, only renew the one in the retryRuns set
          liveApps = HashBasedTable.create();
          for (Table.Cell<String, RunId, YarnTwillController> cell : controllers.cellSet()) {
            if (retryRuns.containsEntry(cell.getRowKey(), cell.getColumnKey())) {
              liveApps.put(cell.getRowKey(), cell.getColumnKey(), cell.getValue());
            }
          }
        }
      }

      Multimap<String, RunId> failureRenews = renewSecureStore(liveApps, renewer, false);

      if (!failureRenews.isEmpty()) {
        // If there are failure during the renewal, schedule a retry with a new Runnable.
        LOG.info("Schedule to retry on secure store renewal for applications {} in {} {}",
                 failureRenews.keySet(), retryDelay, timeUnit.name().toLowerCase());
        try {
          scheduler.schedule(
            createSecureStoreUpdateRunnable(scheduler, renewer, failureRenews, retryDelay, timeUnit),
            retryDelay, timeUnit);
        } catch (RejectedExecutionException e) {
          // If the renewal is stopped, the scheduler will be stopped,
          // hence this exception will be thrown and can be safely ignore.
        }
      }
    }
  };
}