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


Java ListMultimap.putAll方法代碼示例

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


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

示例1: groupTasksByType

import com.google.common.collect.ListMultimap; //導入方法依賴的package包/類
private ListMultimap<Class, Task> groupTasksByType(List<Task> tasks) {
    final Set<Class> taskTypes = new TreeSet<Class>(new Comparator<Class>() {
        public int compare(Class o1, Class o2) {
            return o1.getSimpleName().compareTo(o2.getSimpleName());
        }
    });
    taskTypes.addAll(collect(tasks, new Transformer<Class, Task>() {
        public Class transform(Task original) {
            return getDeclaredTaskType(original);
        }
    }));

    ListMultimap<Class, Task> tasksGroupedByType = ArrayListMultimap.create();
    for (final Class taskType : taskTypes) {
        tasksGroupedByType.putAll(taskType, filter(tasks, new Spec<Task>() {
            public boolean isSatisfiedBy(Task element) {
                return getDeclaredTaskType(element).equals(taskType);
            }
        }));
    }
    return tasksGroupedByType;
}
 
開發者ID:lxxlxx888,項目名稱:Reer,代碼行數:23,代碼來源:TaskDetailPrinter.java

示例2: playerTicketsLoaded

import com.google.common.collect.ListMultimap; //導入方法依賴的package包/類
@Override
public ListMultimap<String, ForgeChunkManager.Ticket> playerTicketsLoaded(ListMultimap<String, ForgeChunkManager.Ticket> tickets, World world)
{
	// We don't care what order the tickets are in, but filter out the invalid ones
	ListMultimap<String, ForgeChunkManager.Ticket> validTickets = ArrayListMultimap.create();

	for (String playerName : tickets.keySet())
	{
		List<ForgeChunkManager.Ticket> playerTickets = new ArrayList<>();

		for (ForgeChunkManager.Ticket tkt : tickets.get(playerName))
		{
			BlockPos ticketPosition = NBTUtil.getPosFromTag(tkt.getModData().getCompoundTag("position"));
			TileEntity te = world.getTileEntity(ticketPosition);
			if (te instanceof TileEntityChunkLoader)
			{
				playerTickets.add(tkt);
			}
		}

		validTickets.putAll(playerName, playerTickets);
	}

	return validTickets;
}
 
開發者ID:DarkMorford,項目名稱:Simple-Chunks,代碼行數:26,代碼來源:ChunkLoadingHandler.java

示例3: getDataMap

import com.google.common.collect.ListMultimap; //導入方法依賴的package包/類
/**
 * Returns a map of the data items.
 * @return a map of items.
 *
 * @see DataMap
 */
@NonNull
@Override
public ListMultimap<String, I> getDataMap() {
    // put all the sets in a multimap. The result is that for each key,
    // there is a sorted list of items from all the layers, including removed ones.
    ListMultimap<String, I> fullItemMultimap = ArrayListMultimap.create();

    for (S resourceSet : mDataSets) {
        ListMultimap<String, I> map = resourceSet.getDataMap();
        for (Map.Entry<String, Collection<I>> entry : map.asMap().entrySet()) {
            fullItemMultimap.putAll(entry.getKey(), entry.getValue());
        }
    }

    return fullItemMultimap;
}
 
開發者ID:tranleduy2000,項目名稱:javaide,代碼行數:23,代碼來源:DataMerger.java

示例4: setPostBlobLoadStateToWritten

import com.google.common.collect.ListMultimap; //導入方法依賴的package包/類
/**
 * Sets the post blob load state to WRITTEN.
 *
 * After a load from the blob file, all items have their state set to nothing.
 * If the load mode is set to incrementalState then we want the items that are in the current
 * merge result to have their state be WRITTEN.
 *
 * This will allow further updates with {@link #mergeData(MergeConsumer, boolean)} to ignore the
 * state at load time and only apply the new changes.
 *
 * @see #loadFromBlob(File, boolean)
 * @see DataItem#isWritten()
 */
private void setPostBlobLoadStateToWritten() {
    ListMultimap<String, I> itemMap = ArrayListMultimap.create();

    // put all the sets into list per keys. The order is important as the lower sets are
    // overridden by the higher sets.
    for (S dataSet : mDataSets) {
        ListMultimap<String, I> map = dataSet.getDataMap();
        for (Map.Entry<String, Collection<I>> entry : map.asMap().entrySet()) {
            itemMap.putAll(entry.getKey(), entry.getValue());
        }
    }

    // the items that represent the current state is the last item in the list for each key.
    for (String key : itemMap.keySet()) {
        List<I> itemList = itemMap.get(key);
        itemList.get(itemList.size() - 1).resetStatusToWritten();
    }
}
 
開發者ID:tranleduy2000,項目名稱:javaide,代碼行數:32,代碼來源:DataMerger.java

示例5: setPostBlobLoadStateToTouched

import com.google.common.collect.ListMultimap; //導入方法依賴的package包/類
/**
 * Sets the post blob load state to TOUCHED.
 *
 * After a load from the blob file, all items have their state set to nothing.
 * If the load mode is not set to incrementalState then we want the items that are in the
 * current merge result to have their state be TOUCHED.
 *
 * This will allow the first use of {@link #mergeData(MergeConsumer, boolean)} to add these
 * to the consumer as if they were new items.
 *
 * @see #loadFromBlob(File, boolean)
 * @see DataItem#isTouched()
 */
private void setPostBlobLoadStateToTouched() {
    ListMultimap<String, I> itemMap = ArrayListMultimap.create();

    // put all the sets into list per keys. The order is important as the lower sets are
    // overridden by the higher sets.
    for (S dataSet : mDataSets) {
        ListMultimap<String, I> map = dataSet.getDataMap();
        for (Map.Entry<String, Collection<I>> entry : map.asMap().entrySet()) {
            itemMap.putAll(entry.getKey(), entry.getValue());
        }
    }

    // the items that represent the current state is the last item in the list for each key.
    for (String key : itemMap.keySet()) {
        List<I> itemList = itemMap.get(key);
        itemList.get(itemList.size() - 1).resetStatusToTouched();
    }
}
 
開發者ID:tranleduy2000,項目名稱:javaide,代碼行數:32,代碼來源:DataMerger.java

示例6: addDependency

import com.google.common.collect.ListMultimap; //導入方法依賴的package包/類
private static void addDependency(List<IvyDependencyMetadata> result, DependencyDescriptor dependencyDescriptor) {
    ModuleRevisionId revisionId = dependencyDescriptor.getDependencyRevisionId();
    ModuleVersionSelector requested = DefaultModuleVersionSelector.newSelector(revisionId.getOrganisation(), revisionId.getName(), revisionId.getRevision());

    ListMultimap<String, String> configMappings = ArrayListMultimap.create();
    for (Map.Entry<String, List<String>> entry : readConfigMappings(dependencyDescriptor).entrySet()) {
        configMappings.putAll(entry.getKey(), entry.getValue());
    }

    List<Artifact> artifacts = Lists.newArrayList();
    for (DependencyArtifactDescriptor ivyArtifact : dependencyDescriptor.getAllDependencyArtifacts()) {
        IvyArtifactName ivyArtifactName = new DefaultIvyArtifactName(ivyArtifact.getName(), ivyArtifact.getType(), ivyArtifact.getExt(), (String) ivyArtifact.getExtraAttributes().get(CLASSIFIER));
        artifacts.add(new Artifact(ivyArtifactName, Sets.newHashSet(ivyArtifact.getConfigurations())));
    }

    List<Exclude> excludes = Lists.newArrayList();
    for (ExcludeRule excludeRule : dependencyDescriptor.getAllExcludeRules()) {
        excludes.add(forIvyExclude(excludeRule));
    }

    result.add(new IvyDependencyMetadata(
        requested,
        dependencyDescriptor.getDynamicConstraintDependencyRevisionId().getRevision(),
        false,
        dependencyDescriptor.isChanging(),
        dependencyDescriptor.isTransitive(),
        configMappings,
        artifacts,
        excludes));
}
 
開發者ID:lxxlxx888,項目名稱:Reer,代碼行數:31,代碼來源:IvyModuleDescriptorConverter.java

示例7: detectPotentialLocksCycle

import com.google.common.collect.ListMultimap; //導入方法依賴的package包/類
/**
 * Algorithm to detect a potential lock cycle.
 *
 * For lock's thread owner check which lock is it trying to take.
 * Repeat recursively. When current thread is found a potential cycle is detected.
 *
 * @see CycleDetectingLock#lockOrDetectPotentialLocksCycle()
 */
private ListMultimap<Long, ID> detectPotentialLocksCycle() {
  final long currentThreadId = Thread.currentThread().getId();
  if (lockOwnerThreadId == null || lockOwnerThreadId == currentThreadId) {
    // if nobody owns this lock, lock cycle is impossible
    // if a current thread owns this lock, we let Guice to handle it
    return ImmutableListMultimap.of();
  }

  ListMultimap<Long, ID> potentialLocksCycle = Multimaps.newListMultimap(
      new LinkedHashMap<Long, Collection<ID>>(),
      new Supplier<List<ID>>() {
        @Override
        public List<ID> get() {
          return Lists.newArrayList();
        }
      });
  // lock that is a part of a potential locks cycle, starts with current lock
  ReentrantCycleDetectingLock lockOwnerWaitingOn = this;
  // try to find a dependency path between lock's owner thread and a current thread
  while (lockOwnerWaitingOn != null && lockOwnerWaitingOn.lockOwnerThreadId != null) {
    Long threadOwnerThreadWaits = lockOwnerWaitingOn.lockOwnerThreadId;
    // in case locks cycle exists lock we're waiting for is part of it
    potentialLocksCycle.putAll(threadOwnerThreadWaits,
        getAllLockIdsAfter(threadOwnerThreadWaits, lockOwnerWaitingOn));

    if (threadOwnerThreadWaits == currentThreadId) {
      // owner thread depends on current thread, cycle detected
      return potentialLocksCycle;
    }
    // going for the next thread we wait on indirectly
    lockOwnerWaitingOn = lockThreadIsWaitingOn.get(threadOwnerThreadWaits);
  }
  // no dependency path from an owner thread to a current thread
  return ImmutableListMultimap.of();
}
 
開發者ID:maetrive,項目名稱:businessworks,代碼行數:44,代碼來源:CycleDetectingLock.java

示例8: makeAssignments

import com.google.common.collect.ListMultimap; //導入方法依賴的package包/類
ListMultimap<Integer,T> makeAssignments() {
  List<WorkWrapper> unassigned = new ArrayList<>();

  for (WorkWrapper work : workList) {
    boolean assigned = assignWork(work);
    if (!assigned) {
      unassigned.add(work);
    }
  }

  assignLeftOvers(unassigned);

  ListMultimap<Integer,T> result = ArrayListMultimap.create();

  final AtomicInteger workCount = new AtomicInteger(0);

  for (FragmentWork fragment : getFragments()) {
    result.putAll(fragment.fragmentId, Lists.transform(fragment.workList, new Function<WorkWrapper, T>() {
      @Override
      public T apply(WorkWrapper workWrapper) {
        workCount.incrementAndGet();
        return workWrapper.work;
      }
    }));
  }
  Preconditions.checkState(workCount.get() == workList.size());
  return result;
}
 
開發者ID:dremio,項目名稱:dremio-oss,代碼行數:29,代碼來源:AssignmentCreator2.java

示例9: getAllPermissions

import com.google.common.collect.ListMultimap; //導入方法依賴的package包/類
/**
 * Returns a combined map of user and group permissions, with group names prefixed by
 * {@link AuthUtil#GROUP_PREFIX}.
 */
public ListMultimap<String,T> getAllPermissions() {
  ListMultimap<String,T> tmp = ArrayListMultimap.create();
  tmp.putAll(userCache);
  for (String group : groupCache.keySet()) {
    tmp.putAll(AuthUtil.toGroupEntry(group), groupCache.get(group));
  }
  return tmp;
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:13,代碼來源:TableAuthManager.java

示例10: postMutationBeforeWAL

import com.google.common.collect.ListMultimap; //導入方法依賴的package包/類
@Override
public Cell postMutationBeforeWAL(ObserverContext<RegionCoprocessorEnvironment> ctx,
    MutationType opType, Mutation mutation, Cell oldCell, Cell newCell) throws IOException {
  // If the HFile version is insufficient to persist tags, we won't have any
  // work to do here
  if (!cellFeaturesEnabled) {
    return newCell;
  }

  // Collect any ACLs from the old cell
  List<Tag> tags = Lists.newArrayList();
  ListMultimap<String,Permission> perms = ArrayListMultimap.create();
  if (oldCell != null) {
    // Save an object allocation where we can
    if (oldCell.getTagsLength() > 0) {
      Iterator<Tag> tagIterator = CellUtil.tagsIterator(oldCell.getTagsArray(),
        oldCell.getTagsOffset(), oldCell.getTagsLength());
      while (tagIterator.hasNext()) {
        Tag tag = tagIterator.next();
        if (tag.getType() != AccessControlLists.ACL_TAG_TYPE) {
          // Not an ACL tag, just carry it through
          if (LOG.isTraceEnabled()) {
            LOG.trace("Carrying forward tag from " + oldCell + ": type " + tag.getType() +
              " length " + tag.getTagLength());
          }
          tags.add(tag);
        } else {
          // Merge the perms from the older ACL into the current permission set
          // TODO: The efficiency of this can be improved. Don't build just to unpack
          // again, use the builder
          AccessControlProtos.UsersAndPermissions.Builder builder =
            AccessControlProtos.UsersAndPermissions.newBuilder();
          ProtobufUtil.mergeFrom(builder, tag.getBuffer(), tag.getTagOffset(), tag.getTagLength());
          ListMultimap<String,Permission> kvPerms =
            ProtobufUtil.toUsersAndPermissions(builder.build());
          perms.putAll(kvPerms);
        }
      }
    }
  }

  // Do we have an ACL on the operation?
  byte[] aclBytes = mutation.getACL();
  if (aclBytes != null) {
    // Yes, use it
    tags.add(new Tag(AccessControlLists.ACL_TAG_TYPE, aclBytes));
  } else {
    // No, use what we carried forward
    if (perms != null) {
      // TODO: If we collected ACLs from more than one tag we may have a
      // List<Permission> of size > 1, this can be collapsed into a single
      // Permission
      if (LOG.isTraceEnabled()) {
        LOG.trace("Carrying forward ACLs from " + oldCell + ": " + perms);
      }
      tags.add(new Tag(AccessControlLists.ACL_TAG_TYPE,
        ProtobufUtil.toUsersAndPermissions(perms).toByteArray()));
    }
  }

  // If we have no tags to add, just return
  if (tags.isEmpty()) {
    return newCell;
  }

  Cell rewriteCell = new TagRewriteCell(newCell, Tag.fromList(tags));
  return rewriteCell;
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:69,代碼來源:AccessController.java


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