当前位置: 首页>>代码示例>>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;未经允许,请勿转载。