當前位置: 首頁>>代碼示例>>Java>>正文


Java ImmutableCollection類代碼示例

本文整理匯總了Java中com.google.common.collect.ImmutableCollection的典型用法代碼示例。如果您正苦於以下問題:Java ImmutableCollection類的具體用法?Java ImmutableCollection怎麽用?Java ImmutableCollection使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ImmutableCollection類屬於com.google.common.collect包,在下文中一共展示了ImmutableCollection類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: afterDone

import com.google.common.collect.ImmutableCollection; //導入依賴的package包/類
@Override
protected final void afterDone() {
  super.afterDone();
  RunningState localRunningState = runningState;
  if (localRunningState != null) {
    // Let go of the memory held by the running state
    this.runningState = null;
    ImmutableCollection<? extends ListenableFuture<? extends InputT>> futures =
        localRunningState.futures;
    boolean wasInterrupted = wasInterrupted();

    if (wasInterrupted()) {
      localRunningState.interruptTask();
    }

    if (isCancelled() & futures != null) {
      for (ListenableFuture<?> future : futures) {
        future.cancel(wasInterrupted);
      }
    }
  }
}
 
開發者ID:zugzug90,項目名稱:guava-mock,代碼行數:23,代碼來源:AggregateFuture.java

示例2: validate

import com.google.common.collect.ImmutableCollection; //導入依賴的package包/類
@Override
public void validate()
{
	if( checkDuplication || forceUnique )
	{
		final Set<String> values = new HashSet<String>();
		for( NameValue nv : namesValues )
		{
			// nv.value is URL encoded, but the name is ok to use
			values.add(nv.getName());
		}
		final ImmutableCollection<String> valuesReadonly = ImmutableSet.copyOf(values);

		// We need to inform the wizard to check for uniqueness every time,
		// no matter what
		final boolean isUnique = getRepository().checkDataUniqueness(getFirstTarget().getXoqlPath(),
			valuesReadonly, !forceUnique);

		setInvalid(forceUnique && !isUnique && !isInvalid(),
			new KeyLabel("wizard.controls.editbox.uniqueerror")); //$NON-NLS-1$
	}
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:23,代碼來源:CShuffleList.java

示例3: immutableMultiMapCollector

import com.google.common.collect.ImmutableCollection; //導入依賴的package包/類
@Test
public void immutableMultiMapCollector() {
	ImmutableMultimap<Integer, Integer> result = Stream.iterate(0, p -> p+1)
			.parallel()
			.limit(GENERATED_ITEMS)
			.collect(Collectors.groupingBy(i -> i % 10));
	
	assertEquals(GENERATED_ITEMS,result.size());
	assertEquals(10,result.asMap().size());
	for (int i=0;i<10;i++) {
		int key=i;
		ImmutableCollection<Integer> values = result.get(key);
		values.forEach(v -> {
			assertEquals(key,v % 10);
		});
	}
}
 
開發者ID:flapdoodle-oss,項目名稱:de.flapdoodle.solid,代碼行數:18,代碼來源:CollectorsTest.java

示例4: removeIf

import com.google.common.collect.ImmutableCollection; //導入依賴的package包/類
public boolean removeIf(Predicate<Node> predicate) {
    boolean result;
    ImmutableCollection<Node> before = getEnduringNodes().values();

    this.nodesLock.lock();
    try {
        result = this.nodes.values().removeIf(predicate);
    } finally {
        this.nodesLock.unlock();
    }

    if (!result) {
        return false;
    }

    invalidateCache();

    ImmutableCollection<Node> after = getEnduringNodes().values();
    this.plugin.getEventFactory().handleNodeClear(this, before, after);
    return true;
}
 
開發者ID:lucko,項目名稱:LuckPerms,代碼行數:22,代碼來源:PermissionHolder.java

示例5: setPermission

import com.google.common.collect.ImmutableCollection; //導入依賴的package包/類
/**
 * Sets a permission node
 *
 * @param node the node to set
 */
public DataMutateResult setPermission(Node node) {
    if (hasPermission(node, false) != Tristate.UNDEFINED) {
        return DataMutateResult.ALREADY_HAS;
    }

    ImmutableCollection<Node> before = getEnduringNodes().values();

    this.nodesLock.lock();
    try {
        this.nodes.put(node.getFullContexts().makeImmutable(), node);
    } finally {
        this.nodesLock.unlock();
    }
    invalidateCache();

    ImmutableCollection<Node> after = getEnduringNodes().values();

    this.plugin.getEventFactory().handleNodeAdd(node, this, before, after);
    return DataMutateResult.SUCCESS;
}
 
開發者ID:lucko,項目名稱:LuckPerms,代碼行數:26,代碼來源:PermissionHolder.java

示例6: setTransientPermission

import com.google.common.collect.ImmutableCollection; //導入依賴的package包/類
/**
 * Sets a transient permission node
 *
 * @param node the node to set
 */
public DataMutateResult setTransientPermission(Node node) {
    if (hasPermission(node, true) != Tristate.UNDEFINED) {
        return DataMutateResult.ALREADY_HAS;
    }

    ImmutableCollection<Node> before = getTransientNodes().values();

    this.transientNodesLock.lock();
    try {
        this.transientNodes.put(node.getFullContexts().makeImmutable(), node);
    } finally {
        this.transientNodesLock.unlock();
    }

    invalidateCache();

    ImmutableCollection<Node> after = getTransientNodes().values();

    this.plugin.getEventFactory().handleNodeAdd(node, this, before, after);
    return DataMutateResult.SUCCESS;
}
 
開發者ID:lucko,項目名稱:LuckPerms,代碼行數:27,代碼來源:PermissionHolder.java

示例7: unsetPermission

import com.google.common.collect.ImmutableCollection; //導入依賴的package包/類
/**
 * Unsets a permission node
 *
 * @param node the node to unset
 */
public DataMutateResult unsetPermission(Node node) {
    if (hasPermission(node, false) == Tristate.UNDEFINED) {
        return DataMutateResult.LACKS;
    }

    ImmutableCollection<Node> before = getEnduringNodes().values();

    this.nodesLock.lock();
    try {
        this.nodes.get(node.getFullContexts().makeImmutable()).removeIf(e -> e.almostEquals(node));
    } finally {
        this.nodesLock.unlock();
    }

    invalidateCache();

    ImmutableCollection<Node> after = getEnduringNodes().values();
    this.plugin.getEventFactory().handleNodeRemove(node, this, before, after);
    return DataMutateResult.SUCCESS;
}
 
開發者ID:lucko,項目名稱:LuckPerms,代碼行數:26,代碼來源:PermissionHolder.java

示例8: unsetTransientPermission

import com.google.common.collect.ImmutableCollection; //導入依賴的package包/類
/**
 * Unsets a transient permission node
 *
 * @param node the node to unset
 */
public DataMutateResult unsetTransientPermission(Node node) {
    if (hasPermission(node, true) == Tristate.UNDEFINED) {
        return DataMutateResult.LACKS;
    }

    ImmutableCollection<Node> before = getTransientNodes().values();

    this.transientNodesLock.lock();
    try {
        this.transientNodes.get(node.getFullContexts().makeImmutable()).removeIf(e -> e.almostEquals(node));
    } finally {
        this.transientNodesLock.unlock();
    }

    invalidateCache();

    ImmutableCollection<Node> after = getTransientNodes().values();
    this.plugin.getEventFactory().handleNodeRemove(node, this, before, after);
    return DataMutateResult.SUCCESS;
}
 
開發者ID:lucko,項目名稱:LuckPerms,代碼行數:26,代碼來源:PermissionHolder.java

示例9: clearNodes

import com.google.common.collect.ImmutableCollection; //導入依賴的package包/類
public boolean clearNodes(ContextSet contextSet) {
    ImmutableCollection<Node> before = getEnduringNodes().values();
    this.nodesLock.lock();
    try {
        this.nodes.removeAll(contextSet.makeImmutable());
    } finally {
        this.nodesLock.unlock();
    }

    invalidateCache();
    ImmutableCollection<Node> after = getEnduringNodes().values();

    if (before.size() == after.size()) {
        return false;
    }

    this.plugin.getEventFactory().handleNodeClear(this, before, after);
    return true;
}
 
開發者ID:lucko,項目名稱:LuckPerms,代碼行數:20,代碼來源:PermissionHolder.java

示例10: clearParents

import com.google.common.collect.ImmutableCollection; //導入依賴的package包/類
public boolean clearParents(boolean giveDefault) {
    ImmutableCollection<Node> before = getEnduringNodes().values();

    this.nodesLock.lock();
    try {
        boolean b = this.nodes.values().removeIf(Node::isGroupNode);
        if (!b) {
            return false;
        }
    } finally {
        this.nodesLock.unlock();
    }

    if (this.getType().isUser() && giveDefault) {
        this.plugin.getUserManager().giveDefaultIfNeeded((User) this, false);
    }

    invalidateCache();
    ImmutableCollection<Node> after = getEnduringNodes().values();
    this.plugin.getEventFactory().handleNodeClear(this, before, after);
    return true;
}
 
開發者ID:lucko,項目名稱:LuckPerms,代碼行數:23,代碼來源:PermissionHolder.java

示例11: clearMeta

import com.google.common.collect.ImmutableCollection; //導入依賴的package包/類
public boolean clearMeta(MetaType type) {
    ImmutableCollection<Node> before = getEnduringNodes().values();

    this.nodesLock.lock();
    try {
        if (!this.nodes.values().removeIf(type::matches)) {
            return false;
        }
    } finally {
        this.nodesLock.unlock();
    }

    invalidateCache();
    ImmutableCollection<Node> after = getEnduringNodes().values();
    this.plugin.getEventFactory().handleNodeClear(this, before, after);
    return true;
}
 
開發者ID:lucko,項目名稱:LuckPerms,代碼行數:18,代碼來源:PermissionHolder.java

示例12: clearMetaKeys

import com.google.common.collect.ImmutableCollection; //導入依賴的package包/類
public boolean clearMetaKeys(String key, boolean temp) {
    ImmutableCollection<Node> before = getEnduringNodes().values();

    this.nodesLock.lock();
    try {
        boolean b = this.nodes.values().removeIf(n -> n.isMeta() && (n.isTemporary() == temp) && n.getMeta().getKey().equalsIgnoreCase(key));
        if (!b) {
            return false;
        }
    } finally {
        this.nodesLock.unlock();
    }

    invalidateCache();
    ImmutableCollection<Node> after = getEnduringNodes().values();
    this.plugin.getEventFactory().handleNodeClear(this, before, after);
    return true;
}
 
開發者ID:lucko,項目名稱:LuckPerms,代碼行數:19,代碼來源:PermissionHolder.java

示例13: InsertQueryImpl

import com.google.common.collect.ImmutableCollection; //導入依賴的package包/類
/**
 * At least one of {@code tx} and {@code match} must be absent.
 *
 * @param vars a collection of Vars to insert
 * @param match the {@link Match} to insert for each result
 * @param tx the graph to execute on
 */
InsertQueryImpl(ImmutableCollection<VarPatternAdmin> vars, Optional<MatchAdmin> match, Optional<GraknTx> tx) {
    // match and graph should never both be present (should get graph from inner match)
    assert(!match.isPresent() || !tx.isPresent());

    if (vars.isEmpty()) {
        throw GraqlQueryException.noPatterns();
    }

    this.match = match;
    this.tx = tx;

    this.originalVars = vars;

    // Get all variables, including ones nested in other variables
    this.vars = vars.stream().flatMap(v -> v.innerVarPatterns().stream()).collect(toImmutableList());

    for (VarPatternAdmin var : this.vars) {
        var.getProperties().forEach(property -> ((VarPropertyInternal) property).checkInsertable(var));
    }
}
 
開發者ID:graknlabs,項目名稱:grakn,代碼行數:28,代碼來源:InsertQueryImpl.java

示例14: getConfigurationForFile

import com.google.common.collect.ImmutableCollection; //導入依賴的package包/類
@Nullable
OCResolveConfiguration getConfigurationForFile(VirtualFile sourceFile) {
  SourceToTargetMap sourceToTargetMap = SourceToTargetMap.getInstance(project);
  ImmutableCollection<TargetKey> targetsForSourceFile =
      sourceToTargetMap.getRulesForSourceFile(VfsUtilCore.virtualToIoFile(sourceFile));
  if (targetsForSourceFile.isEmpty()) {
    return null;
  }

  // If a source file is in two different targets, we can't possibly show how it will be
  // interpreted in both contexts at the same time in the IDE, so just pick the "first" target.
  TargetKey targetKey = targetsForSourceFile.stream().min(TargetKey::compareTo).orElse(null);
  Preconditions.checkNotNull(targetKey);

  return configurationMap.get(targetKey);
}
 
開發者ID:bazelbuild,項目名稱:intellij,代碼行數:17,代碼來源:BlazeConfigurationResolverResult.java

示例15: MockJavaPsiFacade

import com.google.common.collect.ImmutableCollection; //導入依賴的package包/類
MockJavaPsiFacade(
    Project project, PsiManager psiManager, ImmutableCollection<String> classNames) {
  super(project, psiManager, null, null);
  ImmutableMap.Builder<String, PsiClass> classesBuilder = ImmutableMap.builder();
  ImmutableMap.Builder<String, Long> timestampsBuilder = ImmutableMap.builder();
  for (String className : classNames) {
    VirtualFile virtualFile =
        new MockVirtualFile("/src/" + className.replace('.', '/') + ".java");
    PsiFile psiFile = mock(PsiFile.class);
    when(psiFile.getVirtualFile()).thenReturn(virtualFile);
    PsiClass psiClass = mock(PsiClass.class);
    when(psiClass.getContainingFile()).thenReturn(psiFile);
    classesBuilder.put(className, psiClass);
    timestampsBuilder.put(className, virtualFile.getTimeStamp());
  }
  classes = classesBuilder.build();
  timestamps = timestampsBuilder.build();
}
 
開發者ID:bazelbuild,項目名稱:intellij,代碼行數:19,代碼來源:BlazeAndroidModelTest.java


注:本文中的com.google.common.collect.ImmutableCollection類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。