Java Code Examples for com.google.common.collect.ImmutableMultimap#copyOf()

The following examples show how to use com.google.common.collect.ImmutableMultimap#copyOf() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ReflectiveRelMetadataProvider.java    From calcite with Apache License 2.0 6 votes vote down vote up
Space(Multimap<Method, MetadataHandler> providerMap) {
  this.providerMap = ImmutableMultimap.copyOf(providerMap);

  // Find the distinct set of RelNode classes handled by this provider,
  // ordered base-class first.
  for (Map.Entry<Method, MetadataHandler> entry : providerMap.entries()) {
    final Method method = entry.getKey();
    final MetadataHandler provider = entry.getValue();
    for (final Method handlerMethod : provider.getClass().getMethods()) {
      if (couldImplement(handlerMethod, method)) {
        @SuppressWarnings("unchecked") final Class<RelNode> relNodeClass =
            (Class<RelNode>) handlerMethod.getParameterTypes()[0];
        classes.add(relNodeClass);
        handlerMap.put(Pair.of(relNodeClass, method), handlerMethod);
      }
    }
  }
}
 
Example 2
Source File: WorkerModule.java    From bazel with Apache License 2.0 6 votes vote down vote up
@Override
public void registerSpawnStrategies(
    SpawnStrategyRegistry.Builder registryBuilder, CommandEnvironment env) {
  Preconditions.checkNotNull(workerPool);
  SandboxOptions sandboxOptions = env.getOptions().getOptions(SandboxOptions.class);
  ImmutableMultimap<String, String> extraFlags =
      ImmutableMultimap.copyOf(env.getOptions().getOptions(WorkerOptions.class).workerExtraFlags);
  LocalEnvProvider localEnvProvider = LocalEnvProvider.forCurrentOs(env.getClientEnv());
  WorkerSpawnRunner spawnRunner =
      new WorkerSpawnRunner(
          new SandboxHelpers(sandboxOptions.delayVirtualInputMaterialization),
          env.getExecRoot(),
          workerPool,
          extraFlags,
          env.getReporter(),
          createFallbackRunner(env, localEnvProvider),
          localEnvProvider,
          sandboxOptions.symlinkedSandboxExpandsTreeArtifactsInRunfilesTree,
          env.getBlazeWorkspace().getBinTools(),
          env.getLocalResourceManager(),
          // TODO(buchgr): Replace singleton by a command-scoped RunfilesTreeUpdater
          RunfilesTreeUpdater.INSTANCE);
  registryBuilder.registerStrategy(
      new WorkerSpawnStrategy(env.getExecRoot(), spawnRunner), "worker");
}
 
Example 3
Source File: UserCreationTaskTest.java    From timbuctoo with GNU General Public License v3.0 6 votes vote down vote up
@Test
public void executeLetsTheLocalUserCreatorCreateAUser() throws Exception {
  Map<String, String> userInfo = Maps.newHashMap();
  userInfo.put(UserInfoKeys.USER_PID, PID);
  userInfo.put(UserInfoKeys.USER_NAME, USER_NAME);
  userInfo.put(UserInfoKeys.PASSWORD, PWD);
  userInfo.put(UserInfoKeys.GIVEN_NAME, GIVEN_NAME);
  userInfo.put(UserInfoKeys.SURNAME, SURNAME);
  userInfo.put(UserInfoKeys.EMAIL_ADDRESS, EMAIL);
  userInfo.put(UserInfoKeys.ORGANIZATION, ORGANIZATION);
  userInfo.put(UserInfoKeys.VRE_ID, VRE_ID);
  userInfo.put(UserInfoKeys.VRE_ROLE, VRE_ROLE);
  ImmutableMultimap<String, String> immutableMultimap = ImmutableMultimap.copyOf(userInfo.entrySet());

  instance.execute(immutableMultimap, mock(PrintWriter.class));

  verify(localUserCreator).create(userInfo);
}
 
Example 4
Source File: ReflectiveRelMetadataProvider.java    From Quicksql with MIT License 6 votes vote down vote up
Space(Multimap<Method, MetadataHandler> providerMap) {
  this.providerMap = ImmutableMultimap.copyOf(providerMap);

  // Find the distinct set of RelNode classes handled by this provider,
  // ordered base-class first.
  for (Map.Entry<Method, MetadataHandler> entry : providerMap.entries()) {
    final Method method = entry.getKey();
    final MetadataHandler provider = entry.getValue();
    for (final Method handlerMethod : provider.getClass().getMethods()) {
      if (couldImplement(handlerMethod, method)) {
        @SuppressWarnings("unchecked") final Class<RelNode> relNodeClass =
            (Class<RelNode>) handlerMethod.getParameterTypes()[0];
        classes.add(relNodeClass);
        handlerMap.put(Pair.of(relNodeClass, method), handlerMethod);
      }
    }
  }
}
 
Example 5
Source File: StoredPaymentChannelClientStates.java    From GreenBits with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Get a copy of all {@link StoredClientChannel}s
 */
public Multimap<Sha256Hash, StoredClientChannel> getChannelMap() {
    lock.lock();
    try {
        return ImmutableMultimap.copyOf(mapChannels);
    } finally {
        lock.unlock();
    }
}
 
Example 6
Source File: EventBus.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * Unregisters all subscribed methods from provided subscriber object.
 *
 * @param object object to unsubscribe from
 */
public synchronized void unregister(@Nonnull final Object object)
{
	if (subscribers == null)
	{
		return;
	}

	final Multimap<Class, Subscriber> map = HashMultimap.create();
	map.putAll(subscribers);

	for (Class<?> clazz = object.getClass(); clazz != null; clazz = clazz.getSuperclass())
	{
		for (final Method method : clazz.getDeclaredMethods())
		{
			final Subscribe sub = method.getAnnotation(Subscribe.class);

			if (sub == null)
			{
				continue;
			}

			final Class<?> parameterClazz = method.getParameterTypes()[0];
			map.remove(parameterClazz, new Subscriber(object, method, sub.priority(), null));
		}
	}

	subscribers = ImmutableMultimap.copyOf(map);
}
 
Example 7
Source File: CodeReferenceMap.java    From j2objc with Apache License 2.0 5 votes vote down vote up
public CodeReferenceMap build() {
  ImmutableTable.Builder<String, String, ImmutableSet<String>> deadMethodsBuilder =
      ImmutableTable.builder();
  for (Table.Cell<String, String, Set<String>> cell : this.deadMethods.cellSet()) {
    deadMethodsBuilder.put(
        cell.getRowKey(),
        cell.getColumnKey(),
        ImmutableSet.copyOf(cell.getValue()));
  }
  return new CodeReferenceMap(
      ImmutableSet.copyOf(deadClasses),
      deadMethodsBuilder.build(),
      ImmutableMultimap.copyOf(deadFields));
}
 
Example 8
Source File: UsersStateDifference.java    From cloudbreak with Apache License 2.0 5 votes vote down vote up
public static ImmutableMultimap<String, String> calculateGroupMembershipToAdd(UmsUsersState umsState, UsersState ipaState) {
    Multimap<String, String> groupMembershipToAdd = HashMultimap.create();
    umsState.getUsersState().getGroupMembership().forEach((group, user) -> {
        if (!FreeIpaChecks.IPA_UNMANAGED_GROUPS.contains(group) && !ipaState.getGroupMembership().containsEntry(group, user)) {
            LOGGER.debug("adding user : {} to group : {}", user, group);
            groupMembershipToAdd.put(group, user);
        }
    });

    LOGGER.info("groupMembershipToAdd size = {}", groupMembershipToAdd.size());
    LOGGER.debug("groupMembershipToAdd = {}", groupMembershipToAdd.asMap());

    return ImmutableMultimap.copyOf(groupMembershipToAdd);
}
 
Example 9
Source File: StoredPaymentChannelClientStates.java    From green_android with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Get a copy of all {@link StoredClientChannel}s
 */
public Multimap<Sha256Hash, StoredClientChannel> getChannelMap() {
    lock.lock();
    try {
        return ImmutableMultimap.copyOf(mapChannels);
    } finally {
        lock.unlock();
    }
}
 
Example 10
Source File: CorefAnnotation.java    From tac-kbp-eal with MIT License 5 votes vote down vote up
private CorefAnnotation(final Symbol docId, final Multimap<Integer, KBPString> idToCASes,
    final Map<KBPString, Integer> CASesToIDs, final Set<KBPString> unannotated) {
  this.docId = checkNotNull(docId);
  this.idToCASes = ImmutableMultimap.copyOf(idToCASes);
  this.CASesToIDs = ImmutableMap.copyOf(CASesToIDs);
  this.unannotated = ImmutableSet.copyOf(unannotated);
  checkConsistency();
}
 
Example 11
Source File: HarvesterAnimationStateMachine.java    From EmergingTechnology with MIT License 5 votes vote down vote up
@Deprecated
public HarvesterAnimationStateMachine(ImmutableMap<String, ITimeValue> parameters,
        ImmutableMap<String, IClip> clips, ImmutableList<String> states, ImmutableMap<String, String> transitions,
        String startState) {
    this(parameters, clips, states, ImmutableMultimap.copyOf(
            Multimaps.newSetMultimap(Maps.transformValues(transitions, ImmutableSet::of), Sets::newHashSet)),
            startState);
}
 
Example 12
Source File: StoredPaymentChannelClientStates.java    From bcm-android with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Get a copy of all {@link StoredClientChannel}s
 */
public Multimap<Sha256Hash, StoredClientChannel> getChannelMap() {
    lock.lock();
    try {
        return ImmutableMultimap.copyOf(mapChannels);
    } finally {
        lock.unlock();
    }
}
 
Example 13
Source File: BucketBalancer.java    From presto with Apache License 2.0 5 votes vote down vote up
public ClusterState(
        Set<String> activeNodes,
        Map<String, Long> assignedBytes,
        Multimap<Distribution, BucketAssignment> distributionAssignments,
        Map<Distribution, Long> distributionBucketSize)
{
    this.activeNodes = ImmutableSet.copyOf(requireNonNull(activeNodes, "activeNodes is null"));
    this.assignedBytes = ImmutableMap.copyOf(requireNonNull(assignedBytes, "assignedBytes is null"));
    this.distributionAssignments = ImmutableMultimap.copyOf(requireNonNull(distributionAssignments, "distributionAssignments is null"));
    this.distributionBucketSize = ImmutableMap.copyOf(requireNonNull(distributionBucketSize, "distributionBucketSize is null"));
}
 
Example 14
Source File: SchemaResolutionException.java    From yangtools with Eclipse Public License 1.0 5 votes vote down vote up
public SchemaResolutionException(final @NonNull String message, final SourceIdentifier failedSource,
        final Throwable cause, final @NonNull Collection<SourceIdentifier> resolvedSources,
        final @NonNull Multimap<SourceIdentifier, ModuleImport> unsatisfiedImports) {
    super(formatMessage(message, failedSource, resolvedSources, unsatisfiedImports), cause);
    this.failedSource = failedSource;
    this.unsatisfiedImports = ImmutableMultimap.copyOf(unsatisfiedImports);
    this.resolvedSources = ImmutableList.copyOf(resolvedSources);
}
 
Example 15
Source File: AspectParameters.java    From bazel with Apache License 2.0 4 votes vote down vote up
private AspectParameters(Multimap<String, String> attributes) {
  this.attributes = ImmutableMultimap.copyOf(attributes);
}
 
Example 16
Source File: AqueryActionFilter.java    From bazel with Apache License 2.0 4 votes vote down vote up
private AqueryActionFilter(Builder builder) {
  filterMap = ImmutableMultimap.copyOf(builder.filterMap);
}
 
Example 17
Source File: UsersState.java    From cloudbreak with Apache License 2.0 4 votes vote down vote up
public UsersState(
    Set<FmsGroup> groups, Set<FmsUser> users, Multimap<String, String> groupMembership) {
    this.groups = ImmutableSet.copyOf(requireNonNull(groups, "groups is null"));
    this.users = ImmutableSet.copyOf(requireNonNull(users, "users is null"));
    this.groupMembership = ImmutableMultimap.copyOf(requireNonNull(groupMembership, "group membership is null"));
}
 
Example 18
Source File: LanguageServerImpl.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * @since 2.16
 */
protected Multimap<String, Endpoint> getExtensionProviders() {
	return ImmutableMultimap.copyOf(extensionProviders);
}
 
Example 19
Source File: FlowDocumentation.java    From nomulus with Apache License 2.0 4 votes vote down vote up
public ImmutableMultimap<Long, ErrorCase> getErrorsByCode() {
  return ImmutableMultimap.copyOf(errorsByCode);
}
 
Example 20
Source File: VariableScopeExtractor.java    From api-mining with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Return the variable scopes of the given node.
 * 
 * @param node
 * @return
 */
public Multimap<ASTNode, Variable> getVariableScopes(final ASTNode node) {
	variableScopes.clear();
	node.accept(this);
	return ImmutableMultimap.copyOf(variableScopes);
}