本文整理汇总了Java中com.google.common.collect.Multimap.isEmpty方法的典型用法代码示例。如果您正苦于以下问题:Java Multimap.isEmpty方法的具体用法?Java Multimap.isEmpty怎么用?Java Multimap.isEmpty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.common.collect.Multimap
的用法示例。
在下文中一共展示了Multimap.isEmpty方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: combine
import com.google.common.collect.Multimap; //导入方法依赖的package包/类
public static <K, V> Multimap<K, V> combine(Iterable<Multimap<K, V>> maps) {
Multimap<K, V> singleton = null;
ImmutableMultimap.Builder<K, V> builder = null;
for(Multimap<K, V> map : maps) {
if(!map.isEmpty()) {
if(singleton == null) {
singleton = map;
} else {
if(builder == null) {
builder = ImmutableMultimap.builder();
}
builder.putAll(singleton);
builder.putAll(map);
}
}
}
if(builder != null) {
return builder.build();
} else if(singleton != null) {
return singleton;
} else {
return ImmutableMultimap.of();
}
}
示例2: addComparisons
import com.google.common.collect.Multimap; //导入方法依赖的package包/类
public Symbol addComparisons(Symbol symbol, DocTableInfo tableInfo) {
Multimap<ReferenceInfo, GeneratedReferenceInfo> referencedSingleReferences = extractGeneratedReferences(tableInfo);
if (referencedSingleReferences.isEmpty()) {
return symbol;
} else {
Context ctx = new Context(referencedSingleReferences);
return process(symbol, ctx);
}
}
示例3: assertEmpty
import com.google.common.collect.Multimap; //导入方法依赖的package包/类
static void assertEmpty(Multimap<?, ?> multimap) {
if (!multimap.isEmpty()) {
fail("Not true that " + multimap + " is empty");
}
}
示例4: setAllInstitutions
import com.google.common.collect.Multimap; //导入方法依赖的package包/类
private synchronized void setAllInstitutions(Map<Long, InstitutionStatus> map)
{
allInstitutions = ImmutableMap.copyOf(map);
Multimap<Long, Institution> newlyAvailable = ArrayListMultimap.create();
Multimap<Long, Institution> newlyUnavailable = ArrayListMultimap.create(availableInstitutions);
Builder<Long, Institution> availableBuilder = ImmutableMultimap.builder();
ImmutableMap.Builder<Long, Long> schemaBuilder = ImmutableMap.builder();
ImmutableMap.Builder<Long, Institution> instBuilder = ImmutableMap.builder();
for( Entry<Long, InstitutionStatus> entry : allInstitutions.entrySet() )
{
InstitutionStatus instStatus = entry.getValue();
Institution institution = instStatus.getInstitution();
Long schemaId = instStatus.getSchemaId();
if( instStatus.isValid() && institution.isEnabled() )
{
availableBuilder.put(schemaId, institution);
if( !newlyUnavailable.remove(schemaId, institution) )
{
newlyAvailable.put(schemaId, institution);
}
}
long uniqueId = institution.getUniqueId();
schemaBuilder.put(uniqueId, schemaId);
instBuilder.put(uniqueId, institution);
}
availableInstitutions = availableBuilder.build();
schemaMap = schemaBuilder.build();
instMap = instBuilder.build();
if( !newlyAvailable.isEmpty() )
{
eventService.publishApplicationEvent(new InstitutionEvent(InstitutionEventType.AVAILABLE, newlyAvailable));
}
if( !newlyUnavailable.isEmpty() )
{
eventService
.publishApplicationEvent(new InstitutionEvent(InstitutionEventType.UNAVAILABLE, newlyUnavailable));
}
}
示例5: get
import com.google.common.collect.Multimap; //导入方法依赖的package包/类
/**
* Reentrant. If {@code instance} was registered for injection at injector-creation time, this
* method will ensure that all its members have been injected before returning.
*/
public T get(Errors errors) throws ErrorsException {
// skipping acquiring lock if initialization is already finished
if (state == InjectableReferenceState.READY) {
return instance;
}
// acquire lock for current binding to initialize an instance
Multimap<?, ?> lockCycle = lock.lockOrDetectPotentialLocksCycle();
if (!lockCycle.isEmpty()) {
// Potential deadlock detected and creation lock is not taken.
// According to injectAll()'s contract return non-initialized instance.
// This condition should not be possible under the current Guice implementation.
// This clause exists for defensive programming purposes.
// Reasoning:
// get() is called either directly from injectAll(), holds no locks and can not create
// a cycle, or it is called through a singleton scope, which resolves deadlocks by itself.
// Before calling get() object has to be requested for injection.
// Initializer.requestInjection() is called either for constant object bindings, which wrap
// creation into a Singleton scope, or from Binder.requestInjection(), which
// has to use Singleton scope to reuse the same InjectableReference to potentially
// create a lock cycle.
return instance;
}
try {
// lock acquired, current thread owns this instance initialization
switch (state) {
case READY:
return instance;
// When instance depends on itself in the same thread potential dead lock
// is not detected. We have to prevent a stack overflow and we use
// an "injecting" stage to short-circuit a call.
case INJECTING:
return instance;
case VALIDATED:
state = InjectableReferenceState.INJECTING;
break;
case NEW:
throw new IllegalStateException("InjectableReference is not validated yet");
default:
throw new IllegalStateException("Unknown state: " + state);
}
// if in Stage.TOOL, we only want to inject & notify toolable injection points.
// (otherwise we'll inject all of them)
membersInjector.injectAndNotify(instance,
errors.withSource(source),
key,
provisionCallback,
source,
injector.options.stage == Stage.TOOL);
// mark instance as ready to skip a lock on subsequent calls
state = InjectableReferenceState.READY;
return instance;
} finally {
// always release our creation lock, even on failures
lock.unlock();
}
}
示例6: releaseLabel
import com.google.common.collect.Multimap; //导入方法依赖的package包/类
/**
* Deallocates unused labels to device pools.
*
* @param tunnel tunnel between ingress to egress
*/
public void releaseLabel(Tunnel tunnel) {
boolean isLastLabelToPush = false;
checkNotNull(labelRsrcService, LABEL_RESOURCE_SERVICE_NULL);
checkNotNull(pceStore, PCE_STORE_NULL);
Multimap<DeviceId, LabelResource> release = ArrayListMultimap.create();
PceccTunnelInfo pceccTunnelInfo = pceStore.getTunnelInfo(tunnel.tunnelId());
if (pceccTunnelInfo != null) {
List<LspLocalLabelInfo> lspLocalLabelInfoList = pceccTunnelInfo.lspLocalLabelInfoList();
if ((lspLocalLabelInfoList != null) && (lspLocalLabelInfoList.size() > 0)) {
for (Iterator<LspLocalLabelInfo> iterator = lspLocalLabelInfoList.iterator(); iterator.hasNext();) {
LspLocalLabelInfo lspLocalLabelInfo = iterator.next();
DeviceId deviceId = lspLocalLabelInfo.deviceId();
LabelResourceId inLabelId = lspLocalLabelInfo.inLabelId();
LabelResourceId outLabelId = lspLocalLabelInfo.outLabelId();
PortNumber inPort = lspLocalLabelInfo.inPort();
PortNumber outPort = lspLocalLabelInfo.outPort();
// Check whether this is last link label to push
if (!iterator.hasNext()) {
isLastLabelToPush = true;
}
// Push into device
if ((inLabelId != null) && (inPort != null)) {
installLocalLabelRule(deviceId, inLabelId, inPort, tunnel.tunnelId(), isLastLabelToPush,
Long.valueOf(LabelType.IN_LABEL.value), Objective.Operation.REMOVE);
}
if ((outLabelId != null) && (outPort != null)) {
installLocalLabelRule(deviceId, outLabelId, outPort, tunnel.tunnelId(), isLastLabelToPush,
Long.valueOf(LabelType.OUT_LABEL.value), Objective.Operation.REMOVE);
}
// List is stored from egress to ingress. So, using IN label id to release.
// Only one local label is assigned to device (destination node)
// and that is used as OUT label for source node.
// No need to release label for last node in the list from pool because label was not allocated to
// ingress node (source node).
if ((iterator.hasNext()) && (inLabelId != null)) {
LabelResource labelRsc = new DefaultLabelResource(deviceId, inLabelId);
release.put(deviceId, labelRsc);
}
}
}
// Release from label pool
if (!release.isEmpty()) {
labelRsrcService.releaseToDevicePool(release);
}
// Remove tunnel info only if tunnel consumer id is not saved.
// If tunnel consumer id is saved, this tunnel info will be removed during releasing bandwidth.
if (pceccTunnelInfo.tunnelConsumerId() == null) {
pceStore.removeTunnelInfo(tunnel.tunnelId());
}
} else {
log.error("Unable to find PCECC tunnel info in store for a tunnel {}.", tunnel.toString());
}
}