com.google.common.collect.SetMultimap#isEmpty ( )源码实例Demo

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

源代码1 项目: sailfish-core   文件: HtmlReport.java
private void writeReportKnownBugsTable(SetMultimap<String, BugDescription> allKnownBugsMap, SetMultimap<String, BugDescription> reproducedBugsMap, Writer reportWriter) throws IOException, TemplateException {
    if(allKnownBugsMap.isEmpty()) {
        return;
    }

    ReportTable table = new ReportTable(KNOWN_BUGS_TABLE_NAME, Arrays.asList("Test Case", BUG_CATEGORY_COLUMN_NAME, REPRODUCED_COLUMN_NAME, NOT_REPRODUCED_COLUMN_NAME));

    for(String testCaseDescription : allKnownBugsMap.keySet()) {
        Set<BugDescription> allKnownBugs = allKnownBugsMap.get(testCaseDescription);
        Set<BugDescription> reproducedBugs = reproducedBugsMap.get(testCaseDescription);

        List<Map<String, String>> rows = fillKnowBugTable(allKnownBugs, reproducedBugs);
        if (!rows.isEmpty()) {
            rows.get(0).put("Test Case", testCaseDescription);
            table.addRows(rows);
        }
    }

    writeTable(reportWriter, StatusType.NA, table, 4);
}
 
private void checkUniqueness(List<DictionaryValidationError> errors, IMessageStructure message) {

        SetMultimap<String, String> duplicates = HashMultimap.create();

        checkFields(message, duplicates);

        if (!duplicates.isEmpty()) {
            for (String fieldName : duplicates.keySet()) {
                if (duplicates.get(fieldName).size() > 1) {
                    StringBuilder error = new StringBuilder(
                            String.format("Field <strong>[%s]</strong> in <strong>[%s]</strong> message duplicated in ",
                                    fieldName, message.getName()));
                    for (Iterator<String> i = duplicates.get(fieldName).iterator(); i.hasNext();) {
                        error.append(String.format("<strong>[%s]</strong>", i.next()));
                        if (i.hasNext()) {
                            error.append(", ");
                        }
                    }
                    errors.add(new DictionaryValidationError(message.getName(), fieldName, error.toString(),
                            DictionaryValidationErrorLevel.MESSAGE, DictionaryValidationErrorType.ERR_DUPLICATE_NAME));
                }
            }
        }
    }
 
源代码3 项目: tracing-framework   文件: BaggageImpl.java
/** Constructs a {@link BaggageMessage} protobuf message with the contents of this baggage. If this baggage is
 * empty, returns null */
BaggageMessage buildMessage() {
    // Call baggage handlers
    Handlers.preSerialize(this);
    
    // Construct message
    BaggageMessage.Builder b = BaggageMessage.newBuilder();
    for (ByteString namespace : contents.keySet()) {
        SetMultimap<ByteString, ByteString> namespaceData = contents.get(namespace);

        // Namespace should not exist if it has no data
        if (namespaceData.isEmpty()) {
            continue;
        }

        // Construct the namespace data message
        NamespaceData.Builder nb = b.addNamespaceBuilder().setKey(namespace);
        for (ByteString key : namespaceData.keySet()) {
            nb.addBagBuilder().setKey(key).addAllValue(namespaceData.get(key));
        }
    }

    // Return null if the baggage message is empty
    return b.getNamespaceCount() == 0 ? null : b.build();
}
 
源代码4 项目: bazel   文件: ConditionalEdges.java
/** Builds ConditionalEdges from given graph. */
public ConditionalEdges(Digraph<Target> graph) {
  this.map = new HashMap<>();

  for (Node<Target> node : graph.getNodes()) {
    Rule rule = node.getLabel().getAssociatedRule();
    if (rule == null) {
      // rule is null for source files and package groups. Skip them.
      continue;
    }

    SetMultimap<Label, Label> conditions = getAllConditions(rule, RawAttributeMapper.of(rule));
    if (conditions.isEmpty()) {
      // bail early for most common case of no conditions in the rule.
      continue;
    }

    Label nodeLabel = node.getLabel().getLabel();
    for (Node<Target> succ : node.getSuccessors()) {
      Label successorLabel = succ.getLabel().getLabel();
      if (conditions.containsKey(successorLabel)) {
        insert(nodeLabel, successorLabel, conditions.get(successorLabel));
      }
    }
  }
}
 
源代码5 项目: gef   文件: ObservableSetMultimapWrapper.java
@Override
public void clear() {
	SetMultimap<K, V> previousContents = delegateCopy();
	super.clear();
	if (!previousContents.isEmpty()) {
		List<ElementarySubChange<K, V>> elementaryChanges = new ArrayList<>();
		for (K key : previousContents.keySet()) {
			elementaryChanges.add(new ElementarySubChange<>(key,
					previousContents.get(key), Collections.<V> emptySet()));
		}
		helper.fireValueChangedEvent(
				new SetMultimapListenerHelper.AtomicChange<>(this,
						previousContents, elementaryChanges));
	}
}
 
@Override
public void click(MouseEvent e) {
	SetMultimap<IVisualPart<? extends Node>, String> anchorages = getHost().getAnchoragesUnmodifiable();
	if (anchorages == null || anchorages.isEmpty()) {
		return;
	}
	IVisualPart<? extends Node> anchorage = anchorages.keySet().iterator().next();
	ShowHiddenNeighborsPolicy hiddenNeighborsPolicy = anchorage.getAdapter(ShowHiddenNeighborsPolicy.class);
	init(hiddenNeighborsPolicy);
	hiddenNeighborsPolicy.showHiddenNeighbors();
	commit(hiddenNeighborsPolicy);
}
 
源代码7 项目: gef   文件: HideFirstAnchorageOnClickHandler.java
@Override
public void click(MouseEvent e) {
	SetMultimap<IVisualPart<? extends Node>, String> anchorages = getHost().getAnchoragesUnmodifiable();
	if (anchorages == null || anchorages.isEmpty()) {
		return;
	}
	IVisualPart<? extends Node> anchorage = anchorages.keySet().iterator().next();
	HidePolicy hideNodePolicy = anchorage.getAdapter(HidePolicy.class);
	init(hideNodePolicy);
	hideNodePolicy.hide();
	commit(hideNodePolicy);
}
 
源代码8 项目: gef   文件: HoverHandleContainerPart.java
@Override
protected void doRefreshVisual(VBox visual) {
	// check if we have a host
	SetMultimap<IVisualPart<? extends Node>, String> anchorages = getAnchoragesUnmodifiable();
	if (anchorages.isEmpty()) {
		return;
	}

	// determine center location of host visual
	IVisualPart<? extends Node> anchorage = anchorages.keys()
			.iterator().next();
	refreshHandleLocation(anchorage.getVisual());
}
 
源代码9 项目: tracing-framework   文件: BaggageImpl.java
/** Construct a baggage instance from the provided BaggageMessage. If the provided message is invalid, null, or
 * empty, this method will return null
 * 
 * @param message A baggagemessage protobuf
 * @return A baggage instance if the provided message is valid and has contents, null otherwise */
static BaggageImpl create(BaggageMessage message) {
    // Check the message is not null and has some namespaces
    if (message == null || message.getNamespaceCount() == 0) {
        return null;
    }

    // Construct the baggage from the received message
    Map<ByteString, SetMultimap<ByteString, ByteString>> data = Maps.newHashMapWithExpectedSize(message.getNamespaceCount());
    for (NamespaceData namespaceData : message.getNamespaceList()) {
        SetMultimap<ByteString, ByteString> namespace = HashMultimap.create(namespaceData.getBagCount(), 1);
        for (BagData bag : namespaceData.getBagList()) {
            namespace.putAll(bag.getKey(), bag.getValueList());
        }
        if (!namespace.isEmpty()) {
            data.put(namespaceData.getKey(), namespace);
        }
    }

    // If there was no data after all, return null
    if (data.isEmpty()) {
        return null;
    }

    BaggageImpl impl = new BaggageImpl(data);
    Handlers.postDeserialize(impl);
    return impl;
}
 
源代码10 项目: tracing-framework   文件: BaggageImpl.java
/** Remove a key from a specified namespace
 * 
 * @param namespace The namespace the key resides in
 * @param key The key to remove */
public void remove(ByteString namespace, ByteString key) {
    if (namespace != null && key != null) {
        SetMultimap<ByteString, ByteString> namespaceData = contents.get(namespace);
        if (namespaceData != null) {
            namespaceData.removeAll(key);
            if (namespaceData.isEmpty()) {
                contents.remove(namespace);
            }
        }
    }
}
 
源代码11 项目: tracing-framework   文件: BaggageImpl.java
/** Replace the values for a key with the new provided values. Null keys ignored, while null values treated as
 * removing the key
 * 
 * @param namespace The namespace the provided key resides in, 
 * @param key The key to replace values for
 * @param values These values replace existing values for the key */
public void replace(ByteString namespace, ByteString key, Iterable<? extends ByteString> values) {
    if (namespace != null && key != null) {
        if (values == null) {
            remove(namespace, key);
        } else {
            SetMultimap<ByteString, ByteString> namespaceData = modifyKey(namespace, key);
            namespaceData.putAll(key, values);
            namespaceData.remove(key, null);
            if (namespaceData.isEmpty()) {
                contents.remove(namespace);
            }
        }
    }
}
 
源代码12 项目: PGM   文件: KitParser.java
public AttributeKit parseAttributeKit(Element el) throws InvalidXMLException {
  SetMultimap<String, AttributeModifier> modifiers = parseAttributeModifiers(el);
  attributeModifiers.addAll(modifiers.values());
  return modifiers.isEmpty() ? null : new AttributeKit(modifiers);
}
 
源代码13 项目: gef   文件: SetMultimapExpression.java
@Override
public boolean isEmpty() {
	final SetMultimap<K, V> setMultimap = get();
	return (setMultimap == null) ? EMPTY_SETMULTIMAP.isEmpty()
			: setMultimap.isEmpty();
}
 
源代码14 项目: swift-t   文件: WaitCoalescer.java
/**
 * Try to push down waits from current block into child blocks
 * @param logger
 * @param fn
 * @param block
 * @param currContext
 * @return
 */
private boolean pushDownWaits(Logger logger, Program prog, Function fn,
                              Block block, ExecContext currContext) {
  SetMultimap<Var, InstOrCont> waitMap = buildWaiterMap(prog, block);

  if (logger.isTraceEnabled()) {
    logger.trace("waitMap keys: " + waitMap.keySet());
  }

  if (waitMap.isEmpty()) {
    // If waitMap is empty, can't push anything down, so just shortcircuit
    return false;
  }
  boolean changed = false;

  HashSet<Continuation> allPushedDown = new HashSet<Continuation>();
  ArrayList<Continuation> contCopy =
              new ArrayList<Continuation>(block.getContinuations());
  for (Continuation c: contCopy) {
    if (allPushedDown.contains(c)) {
      // Was moved
      continue;
    }
    ExecContext newContext = canPushDownInto(c, currContext);
    if (newContext != null) {
      for (Block innerBlock: c.getBlocks()) {
        StackLite<Continuation> ancestors =
                                      new StackLite<Continuation>();
        ancestors.push(c);
        PushDownResult pdRes =
             pushDownWaitsRec(logger, fn, block, currContext, ancestors,
                              innerBlock, newContext, waitMap);
         changed = changed || pdRes.anyChanges;
        /* The list of continuations might be modified as continuations are
         * pushed down - track which ones are relocated */
        allPushedDown.addAll(pdRes.relocated);
      }
    }
  }
  return changed;
}