List of usage examples for com.google.common.collect SetMultimap isEmpty
boolean isEmpty();
From source file:dagger.internal.codegen.ComponentHierarchyValidator.java
/** * Checks that components do not have any scopes that are also applied on any of their ancestors. *///from www . j a v a2s . c o m private void validateScopeHierarchy(ValidationReport.Builder<TypeElement> report, ComponentDescriptor subject, SetMultimap<ComponentDescriptor, Scope> scopesByComponent) { scopesByComponent.putAll(subject, subject.scopes()); for (ComponentDescriptor child : subject.subcomponents()) { validateScopeHierarchy(report, child, scopesByComponent); } scopesByComponent.removeAll(subject); Predicate<Scope> subjectScopes = subject.kind().isProducer() // TODO(beder): validate that @ProductionScope is only applied on production components ? and(in(subject.scopes()), not(equalTo(Scope.productionScope(elements)))) : in(subject.scopes()); SetMultimap<ComponentDescriptor, Scope> overlappingScopes = Multimaps.filterValues(scopesByComponent, subjectScopes); if (!overlappingScopes.isEmpty()) { StringBuilder error = new StringBuilder().append(subject.componentDefinitionType().getQualifiedName()) .append(" has conflicting scopes:"); for (Map.Entry<ComponentDescriptor, Scope> entry : overlappingScopes.entries()) { Scope scope = entry.getValue(); error.append("\n ").append(entry.getKey().componentDefinitionType().getQualifiedName()) .append(" also has ").append(scope.getReadableSource()); } report.addItem(error.toString(), compilerOptions.scopeCycleValidationType().diagnosticKind().get(), subject.componentDefinitionType()); } }
From source file:org.sosy_lab.cpachecker.core.reachedset.PseudoPartitionedReachedSet.java
@Override public void remove(AbstractState pState) { super.remove(pState); Object key = getPartitionKey(pState); Comparable<?> pseudoKey = getPseudoPartitionKey(pState); Object pseudoHash = getPseudoHashCode(pState); SetMultimap<Object, AbstractState> states = partitionedReached.get(key, pseudoKey); if (states != null) { states.remove(pseudoHash, pState); if (states.isEmpty()) { partitionedReached.remove(key, pseudoKey); }//ww w .j a v a2 s . co m } }
From source file:io.tilt.minka.business.leader.distributor.SpillOverBalancer.java
protected final void balance(final PartitionTable table, final Reallocation realloc, final List<Shard> onlineShards, final Set<ShardDuty> dangling, final Set<ShardDuty> creations, final Set<ShardDuty> deletions, final int accounted) { final long maxValue = getConfig().getBalancerSpillOverMaxValue(); if (maxValue <= 0) { final Shard receptorShard = getAnyReceptorShard(table, onlineShards); logger.info("{}: For Unbounded duties (max = 0) found Shard receptor: {}", getClass().getSimpleName(), receptorShard);// ww w. jav a 2s . co m creations.addAll(dangling); registerMigrationFromOthersToOne(table, realloc, receptorShard); registerCreations(creations, realloc, new CircularCollection<>(Arrays.asList(receptorShard))); } else { logger.info("{}: Computing Spilling strategy: {} with a Max Value: {}", getClass().getSimpleName(), getConfig().getBalancerSpillOverStrategy(), maxValue); boolean loadStrat = getConfig().getBalancerSpillOverStrategy() == SpillBalancerStrategy.WORKLOAD; final Map<Shard, AtomicLong> spaceByReceptor = new HashMap<>(); final SetMultimap<Shard, ShardDuty> trans = collectTransceivers(table, loadStrat, spaceByReceptor, maxValue); if (spaceByReceptor.isEmpty() && !trans.isEmpty()) { logger.warn("{}: Couldnt find receptors to spill over to", getClass().getSimpleName()); } else { logger.info("{}: Shard with space for allocating Duties: {}", getClass().getSimpleName(), spaceByReceptor); final List<ShardDuty> unfitting = new ArrayList<>(); final List<ShardDuty> dutiesForBalance = new ArrayList<>(); dutiesForBalance.addAll(creations); // priority for new comers dutiesForBalance.addAll(dangling); if (loadStrat) { // so we can get the biggest accomodation of duties instead of the heaviest Collections.sort(dutiesForBalance, Collections.reverseOrder(Workload.getComparator())); } registerNewcomers(realloc, loadStrat, spaceByReceptor, unfitting, dutiesForBalance); // then move those surplussing registerMigrations(realloc, loadStrat, spaceByReceptor, unfitting, trans, maxValue); for (ShardDuty unfit : unfitting) { logger.error("{}: Add Shards !! No receptor has space for Duty: {}", getClass().getSimpleName(), unfit); } } } }
From source file:eu.esdihumboldt.hale.ui.style.handler.TypeStyleHandler.java
/** * @see IHandler#execute(ExecutionEvent) *//* ww w .ja v a 2 s .com*/ @Override public Object execute(ExecutionEvent event) throws ExecutionException { // collect types and associated data sets SetMultimap<DataSet, TypeDefinition> types = collectTypesFromSelection(event); Pair<TypeDefinition, DataSet> typeInfo = null; // select a type if (types.size() == 1) { Entry<DataSet, TypeDefinition> entry = types.entries().iterator().next(); typeInfo = new Pair<TypeDefinition, DataSet>(entry.getValue(), entry.getKey()); } else if (!types.isEmpty()) { // choose through dialog DataSetTypeSelectionDialog dialog = new DataSetTypeSelectionDialog( Display.getCurrent().getActiveShell(), "Multiple types: select which to change the style for", null, types); if (dialog.open() == DataSetTypeSelectionDialog.OK) { typeInfo = dialog.getObject(); } } if (typeInfo != null) { try { FeatureStyleDialog dialog = new FeatureStyleDialog(typeInfo.getFirst(), typeInfo.getSecond()); dialog.setBlockOnOpen(false); dialog.open(); } catch (Exception e) { throw new ExecutionException("Could not open style dialog", e); } } return null; }
From source file:org.opendaylight.groupbasedpolicy.renderer.ofoverlay.arp.ArpTasker.java
/** * Uses ARP to get MAC for the given L3 endpoint. Tries to find MAC for IP from * {@link EndpointL3#getKey()}.<br> * {@link EndpointL3#getNetworkContainment()} has to point to a {@link Subnet}.<br> * ARP Request is sent from all node connectors obtaining from * {@link OfOverlayNodeConfig#getExternalInterfaces()}<br> * MAC address obtained from ARP reply is added to the given L3 endpoint (if still exits).<br> * Also an {@link Endpoint} is created based on MAC If the subnet from network containment point * to {@link L2BridgeDomain} directly or throught {@link L2FloodDomain}. * * @param l3Ep the L3 endpoint which needs to have an MAC address *//* w ww . j a v a 2s . com*/ public void addMacForL3EpAndCreateEp(final EndpointL3 l3Ep) { final Ipv4Address tpa = getIPv4Addresses(l3Ep); if (tpa == null) { LOG.debug("L3 endpoint {} does not contain IPv4 address.", l3Ep.getKey()); return; } ReadOnlyTransaction rTx = dataProvider.newReadOnlyTransaction(); final SetMultimap<Node, Pair<InstanceIdentifier<NodeConnector>, MacAddress>> extNcWithMacByNode = readNodesWithExternalIfaces( rTx); if (extNcWithMacByNode.isEmpty()) { LOG.debug("No node with external interface was found."); rTx.close(); return; } final Ipv4Address senderIpAddress = createSenderIpAddress(l3Ep, rTx); if (senderIpAddress == null) { LOG.warn("Cannot create sender IPv4 address for L3 endpoint {}", l3Ep); rTx.close(); return; } rTx.close(); for (final Node node : extNcWithMacByNode.keySet()) { final InstanceIdentifier<Node> nodeIid = InstanceIdentifier.builder(Nodes.class) .child(Node.class, node.getKey()).build(); final NodeRef nodeRef = new NodeRef(nodeIid); List<ListenableFuture<RpcResult<AddFlowOutput>>> arpFlowResultFutures = new ArrayList<>(); List<Pair<RemoveFlowInput, EndpointL3Key>> flowsForRemove = new ArrayList<>(); for (final Pair<InstanceIdentifier<NodeConnector>, MacAddress> extNcIidAndMac : extNcWithMacByNode .get(node)) { final ArpMessageAddress senderAddress = new ArpMessageAddress(extNcIidAndMac.getRight(), senderIpAddress); NodeConnectorId ncId = extNcIidAndMac.getLeft() .firstKeyOf(NodeConnector.class, NodeConnectorKey.class).getId(); final Flow arpReplyToControllerFlow = createArpReplyToControllerFlow(senderAddress, tpa, ncId); flowsForRemove.add(new ImmutablePair<>( new RemoveFlowInputBuilder(arpReplyToControllerFlow).setNode(nodeRef).build(), l3Ep.getKey())); final InstanceIdentifier<Flow> flowIid = createFlowIid(arpReplyToControllerFlow, nodeIid); Future<RpcResult<AddFlowOutput>> futureAddFlowResult = flowService .addFlow(new AddFlowInputBuilder(arpReplyToControllerFlow).setFlowRef(new FlowRef(flowIid)) .setNode(nodeRef).build()); arpFlowResultFutures.add(JdkFutureAdapters.listenInPoolThread(futureAddFlowResult)); } requestInfoByKey.putAll(createKey(node.getId(), tpa), flowsForRemove); ListenableFuture<List<RpcResult<AddFlowOutput>>> futureArpFlowResults = Futures .allAsList(arpFlowResultFutures); Futures.addCallback(futureArpFlowResults, new FutureCallback<List<RpcResult<AddFlowOutput>>>() { @Override public void onSuccess(List<RpcResult<AddFlowOutput>> result) { for (RpcResult<AddFlowOutput> addFlowResult : result) { if (!addFlowResult.isSuccessful()) { LOG.warn("An ARP Reply to Controller flow was not created on node {} \nErrors: {}", node.getId().getValue(), addFlowResult.getErrors()); continue; } } LOG.debug("ARP Reply to Controller flows were created on node {}", node.getId().getValue()); for (final Pair<InstanceIdentifier<NodeConnector>, MacAddress> extNcIidAndMac : extNcWithMacByNode .get(node)) { final ArpMessageAddress senderAddress = new ArpMessageAddress(extNcIidAndMac.getRight(), senderIpAddress); ListenableFuture<RpcResult<Void>> futureSendArpResult = arpSender.sendArp(senderAddress, tpa, extNcIidAndMac.getLeft()); Futures.addCallback(futureSendArpResult, logResult(tpa, extNcIidAndMac.getLeft())); } } @Override public void onFailure(Throwable t) { LOG.error( "Illegal state - Installation of ARP flows on node {} failed. Node can contain just some ARP flows.", node.getId(), t); } }); } }
From source file:org.jetbrains.jet.lang.resolve.calls.smartcasts.DelegatingDataFlowInfo.java
@NotNull @Override/* w ww. jav a 2s .c o m*/ public DataFlowInfo or(@NotNull DataFlowInfo otherInfo) { if (otherInfo == EMPTY) return EMPTY; if (this == EMPTY) return EMPTY; if (this == otherInfo) return this; assert otherInfo instanceof DelegatingDataFlowInfo : "Unknown DataFlowInfo type: " + otherInfo; DelegatingDataFlowInfo other = (DelegatingDataFlowInfo) otherInfo; Map<DataFlowValue, Nullability> nullabilityMapBuilder = Maps.newHashMap(); for (Map.Entry<DataFlowValue, Nullability> entry : other.getCompleteNullabilityInfo().entrySet()) { DataFlowValue key = entry.getKey(); Nullability otherFlags = entry.getValue(); Nullability thisFlags = getNullability(key); nullabilityMapBuilder.put(key, thisFlags.or(otherFlags)); } SetMultimap<DataFlowValue, JetType> myTypeInfo = getCompleteTypeInfo(); SetMultimap<DataFlowValue, JetType> otherTypeInfo = other.getCompleteTypeInfo(); SetMultimap<DataFlowValue, JetType> newTypeInfo = newTypeInfo(); for (DataFlowValue key : Sets.intersection(myTypeInfo.keySet(), otherTypeInfo.keySet())) { Set<JetType> thisTypes = myTypeInfo.get(key); Set<JetType> otherTypes = otherTypeInfo.get(key); newTypeInfo.putAll(key, Sets.intersection(thisTypes, otherTypes)); } if (nullabilityMapBuilder.isEmpty() && newTypeInfo.isEmpty()) { return EMPTY; } return new DelegatingDataFlowInfo(null, ImmutableMap.copyOf(nullabilityMapBuilder), newTypeInfo); }
From source file:org.jetbrains.kotlin.resolve.calls.smartcasts.DelegatingDataFlowInfo.java
@NotNull @Override// w ww . j a v a2 s . co m public DataFlowInfo or(@NotNull DataFlowInfo otherInfo) { if (otherInfo == EMPTY) return EMPTY; if (this == EMPTY) return EMPTY; if (this == otherInfo) return this; assert otherInfo instanceof DelegatingDataFlowInfo : "Unknown DataFlowInfo type: " + otherInfo; DelegatingDataFlowInfo other = (DelegatingDataFlowInfo) otherInfo; Map<DataFlowValue, Nullability> nullabilityMapBuilder = Maps.newHashMap(); for (Map.Entry<DataFlowValue, Nullability> entry : other.getCompleteNullabilityInfo().entrySet()) { DataFlowValue key = entry.getKey(); Nullability otherFlags = entry.getValue(); Nullability thisFlags = getNullability(key); nullabilityMapBuilder.put(key, thisFlags.or(otherFlags)); } SetMultimap<DataFlowValue, KotlinType> myTypeInfo = getCompleteTypeInfo(); SetMultimap<DataFlowValue, KotlinType> otherTypeInfo = other.getCompleteTypeInfo(); SetMultimap<DataFlowValue, KotlinType> newTypeInfo = newTypeInfo(); for (DataFlowValue key : Sets.intersection(myTypeInfo.keySet(), otherTypeInfo.keySet())) { Set<KotlinType> thisTypes = myTypeInfo.get(key); Set<KotlinType> otherTypes = otherTypeInfo.get(key); newTypeInfo.putAll(key, Sets.intersection(thisTypes, otherTypes)); } if (nullabilityMapBuilder.isEmpty() && newTypeInfo.isEmpty()) { return EMPTY; } return new DelegatingDataFlowInfo(null, ImmutableMap.copyOf(nullabilityMapBuilder), newTypeInfo); }
From source file:org.jetbrains.kotlin.resolve.calls.smartcasts.DelegatingDataFlowInfo.java
@Override @NotNull/*w w w. ja v a2s .c o m*/ public DataFlowInfo equate(@NotNull DataFlowValue a, @NotNull DataFlowValue b) { Map<DataFlowValue, Nullability> builder = Maps.newHashMap(); Nullability nullabilityOfA = getNullability(a); Nullability nullabilityOfB = getNullability(b); boolean changed = false; changed |= putNullability(builder, a, nullabilityOfA.refine(nullabilityOfB)); changed |= putNullability(builder, b, nullabilityOfB.refine(nullabilityOfA)); SetMultimap<DataFlowValue, KotlinType> newTypeInfo = newTypeInfo(); newTypeInfo.putAll(a, collectTypesFromMeAndParents(b)); newTypeInfo.putAll(b, collectTypesFromMeAndParents(a)); if (!a.getType().equals(b.getType())) { // To avoid recording base types of own type if (!TypeUtilsKt.isSubtypeOf(a.getType(), b.getType())) { newTypeInfo.put(a, b.getType()); } if (!TypeUtilsKt.isSubtypeOf(b.getType(), a.getType())) { newTypeInfo.put(b, a.getType()); } } changed |= !newTypeInfo.isEmpty(); return !changed ? this : new DelegatingDataFlowInfo(this, ImmutableMap.copyOf(builder), newTypeInfo.isEmpty() ? EMPTY_TYPE_INFO : newTypeInfo); }
From source file:org.jetbrains.kotlin.resolve.calls.smartcasts.DelegatingDataFlowInfo.java
@Override @NotNull// w w w .j a v a 2 s .c o m public DataFlowInfo assign(@NotNull DataFlowValue a, @NotNull DataFlowValue b) { Map<DataFlowValue, Nullability> nullability = Maps.newHashMap(); Nullability nullabilityOfB = getNullability(b); putNullability(nullability, a, nullabilityOfB); SetMultimap<DataFlowValue, KotlinType> newTypeInfo = newTypeInfo(); Set<KotlinType> typesForB = getPossibleTypes(b); // Own type of B must be recorded separately, e.g. for a constant // But if its type is the same as A or it's null, there is no reason to do it // because usually null type or own type are not saved in this set if (nullabilityOfB.canBeNonNull() && !a.getType().equals(b.getType())) { typesForB.add(b.getType()); } newTypeInfo.putAll(a, typesForB); return new DelegatingDataFlowInfo(this, ImmutableMap.copyOf(nullability), newTypeInfo.isEmpty() ? EMPTY_TYPE_INFO : newTypeInfo, a); }
From source file:org.xbib.tools.merge.zdb.entities.Manifestation.java
public String build(XContentBuilder builder, String tag, Set<String> visited) throws IOException { if (visited != null) { if (visited.contains(externalID)) { return null; }//from w w w. j a v a 2s . c o m visited.add(externalID); } String id = tag != null ? tag + "." + externalID : externalID; builder.startObject(); builder.field("@id", id).field("@type", "Manifestation").fieldIfNotNull("@tag", tag).field("key", getKey()) .field("title", title()); String s = corporateName(); if (s != null) { builder.field("corporateName", s); } s = meetingName(); if (s != null) { builder.field("meetingName", s); } builder.field("country", country()).field("language", language()).field("publishedat", publisherPlace()) .field("publishedby", publisher()).field("contenttype", contentType()) .field("mediatype", mediaType()).field("carriertype", carrierType()).field("firstdate", firstDate()) .field("lastdate", lastDate()); if (greenDates != null && !greenDates.isEmpty()) { builder.field("greendate", greenDates); } if (hasIdentifiers()) { builder.field("identifiers", getIdentifiers()); } if (isSubseries()) { builder.field("subseries", isSubseries()); } if (isSupplement()) { builder.field("supplement", isSupplement()); } // list external relations for linking synchronized (externalRelations) { SetMultimap<String, String> map = externalRelations; if (!map.isEmpty()) { builder.startArray("relations"); for (String rel : map.keySet()) { for (String relid : map.get(rel)) { builder.startObject().field("@id", relid).field("@type", "Manifestation") .field("@label", rel).endObject(); } } builder.endArray(); } } if (hasLinks()) { builder.array("links", getLinks()); } // list monographic volumes if (!volumeIDs.isEmpty()) { builder.array("volumeids", volumeIDs); } if (!volumes.isEmpty()) { synchronized (volumes) { builder.startArray("volumes"); int count = 0; for (Volume volume : volumes) { volume.build(builder, tag, null); count++; } builder.endArray(); builder.field("volumescount", count); } } builder.endObject(); return id; }