com.google.common.collect.ListMultimap#putAll ( )源码实例Demo

下面列出了com.google.common.collect.ListMultimap#putAll ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: pushfish-android   文件: TaskDetailPrinter.java
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;
}
 
源代码2 项目: java-n-IDE-for-Android   文件: DataMerger.java
/**
 * 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;
}
 
源代码3 项目: Pushjet-Android   文件: TaskDetailPrinter.java
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;
}
 
源代码4 项目: javaide   文件: DataMerger.java
/**
 * 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(java.io.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();
    }
}
 
源代码5 项目: Pushjet-Android   文件: TaskDetailPrinter.java
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;
}
 
源代码6 项目: hmftools   文件: SageApplication.java
@NotNull
private ListMultimap<Chromosome, GenomeRegion> panelWithHotspots(@NotNull final ListMultimap<Chromosome, VariantHotspot> hotspots)
        throws IOException {
    final ListMultimap<Chromosome, GenomeRegion> initialPanel = readPanel(config.panelBed());
    final ListMultimap<Chromosome, GenomeRegion> result = ArrayListMultimap.create();

    for (HumanChromosome chromosome : HumanChromosome.values()) {
        final GenomeRegions builder = new GenomeRegions(chromosome.toString());
        if (initialPanel.containsKey(chromosome)) {
            initialPanel.get(chromosome).forEach(x -> builder.addRegion(x.start(), x.end()));
        }
        if (hotspots.containsKey(chromosome)) {
            hotspots.get(chromosome).forEach(x -> builder.addPosition(x.position()));
        }

        result.putAll(chromosome, builder.build());
    }

    return result;
}
 
源代码7 项目: Strata   文件: FpmlDocument.java
private static ImmutableListMultimap<String, String> parseParties(XmlElement root) {
  ListMultimap<String, String> parties = ArrayListMultimap.create();
  for (XmlElement child : root.getChildren("party")) {
    parties.putAll(child.getAttribute(ID), findPartyIds(child));
  }
  return ImmutableListMultimap.copyOf(parties);
}
 
源代码8 项目: schemaorg-java   文件: JsonLdSerializer.java
private Thing readObject(JsonReader reader) throws IOException {
  reader.beginObject();
  Multimap<String, ValueType> properties = LinkedListMultimap.create();
  ListMultimap<String, Thing> reverseMap = LinkedListMultimap.create();
  String typeName = null;
  while (reader.hasNext()) {
    String key = reader.nextName();
    if (JsonLdConstants.TYPE.equals(key)) {
      typeName = reader.nextString();
    } else if (JsonLdConstants.CONTEXT.equals(key)) {
      properties.putAll(key, readContext(reader));
    } else if (JsonLdConstants.REVERSE.equals(key)) {
      reverseMap.putAll(readReverse(reader));
    } else {
      properties.putAll(
          key, readInternal(reader, JsonLdConstants.ID.equals(key) /* acceptNull */));
    }
  }
  reader.endObject();
  if (Strings.isNullOrEmpty(typeName)) {
    // Treat any unrecognized types as Thing.
    typeName = THING;
  }
  // Value of @type should be short type name or full type name.
  // Doesn't support relative IRI or compact IRI for now.
  return buildSchemaOrgObject(typeName, properties, reverseMap);
}
 
源代码9 项目: hmftools   文件: CountSupplier.java
@NotNull
private static Multimap<Chromosome, ReadCount> fromFutures(List<Future<ChromosomeReadCount>> futures)
        throws ExecutionException, InterruptedException {
    final ListMultimap<Chromosome, ReadCount> readCounts = ArrayListMultimap.create();
    for (Future<ChromosomeReadCount> future : futures) {
        final ChromosomeReadCount readCount = future.get();
        final Chromosome chromosome = readCount.chromosome();
        final List<ReadCount> result = readCount.readCount();

        readCounts.putAll(chromosome, result);
    }

    return readCounts;
}
 
源代码10 项目: businessworks   文件: CycleDetectingLock.java
/**
 * 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();
}
 
源代码11 项目: artemis   文件: RegistryRepository.java
public ListMultimap<Service, Lease<Instance>> getLeases(Collection<String> serviceIds) {
    ListMultimap<Service, Lease<Instance>> leases = ArrayListMultimap.create();
    for (String serviceId : serviceIds) {
        Service service = getApplicationInternal(serviceId);
        leases.putAll(service, getLeases(serviceId));
    }

    return leases;
}
 
源代码12 项目: artemis   文件: RegistryRepository.java
public ListMultimap<Service, Lease<Instance>> getLeases(LeaseManager<Instance> leaseManager) {
    ListMultimap<Service, Lease<Instance>> leases = ArrayListMultimap.create();
    for (String serviceId : _leases.keySet()) {
        Service service = getApplicationInternal(serviceId);
        Collection<Lease<Instance>> serviceLeases = getLeases(serviceId, leaseManager);
        if (CollectionValues.isNullOrEmpty(serviceLeases))
            continue;

        leases.putAll(service, serviceLeases);
    }

    return leases;
}
 
源代码13 项目: artemis   文件: RegistryRepository.java
public ListMultimap<Service, Lease<Instance>> getLeases(Collection<String> serviceIds, LeaseManager<Instance> leaseManager) {
    ListMultimap<Service, Lease<Instance>> leases = ArrayListMultimap.create();
    for (String serviceId : serviceIds) {
        Service service = getApplicationInternal(serviceId);
        leases.putAll(service, getLeases(serviceId, leaseManager));
    }

    return leases;
}
 
private ListMultimap<String, String> getTestElementsById() {
  ListMultimap<String, String> elementsById = ArrayListMultimap.create();
  elementsById.putAll("1", asList("V1", "V2", "V3"));
  elementsById.putAll("2", asList("V4", "V5", "V6"));
  elementsById.putAll("3", asList("V1", "V2"));
  elementsById.putAll("4", asList("V2", "V1"));
  elementsById.putAll("5", singleton("V10"));
  elementsById.putAll("6", emptySet());
  return elementsById;
}
 
源代码15 项目: phoenix   文件: JoinCompiler.java
public static PTableWrapper mergeProjectedTables(PTableWrapper lWrapper, PTableWrapper rWrapper, boolean innerJoin) throws SQLException {
	PTable left = lWrapper.getTable();
	PTable right = rWrapper.getTable();
	List<PColumn> merged = new ArrayList<PColumn>();
	merged.addAll(left.getColumns());
	int position = merged.size();
	for (PColumn c : right.getColumns()) {
		if (!SchemaUtil.isPKColumn(c)) {
			PColumnImpl column = new PColumnImpl(c.getName(), 
					PNameFactory.newName(ScanProjector.VALUE_COLUMN_FAMILY), c.getDataType(), 
					c.getMaxLength(), c.getScale(), innerJoin ? c.isNullable() : true, position++, 
					c.getColumnModifier());
			merged.add(column);
		}
	}
    if (left.getBucketNum() != null) {
        merged.remove(0);
    }
    PTable t = PTableImpl.makePTable(left.getSchemaName(), PNameFactory.newName(SchemaUtil.getTableName(left.getName().getString(), right.getName().getString())),
            left.getType(), left.getIndexState(), left.getTimeStamp(), left.getSequenceNumber(), left.getPKName(), left.getBucketNum(), merged, left.getParentTableName(),
            left.getIndexes(), left.isImmutableRows(), null, null, null, null, PTable.DEFAULT_DISABLE_WAL, left.isMultiTenant(), left.getViewType());

    ListMultimap<String, String> mergedMap = ArrayListMultimap.<String, String>create();
    mergedMap.putAll(lWrapper.getColumnNameMap());
    mergedMap.putAll(rWrapper.getColumnNameMap());
    
    return new PTableWrapper(t, mergedMap);
}
 
源代码16 项目: hmftools   文件: ClusterFactory.java
@NotNull
private ListMultimap<Chromosome, Cluster> cluster(@NotNull final Multimap<Chromosome, SVSegment> variantPositions,
        @NotNull final Multimap<Chromosome, PCFPosition> pcfPositions, @NotNull final ListMultimap<Chromosome, CobaltRatio> ratios) {
    ListMultimap<Chromosome, Cluster> clusters = ArrayListMultimap.create();
    for (Chromosome chromosome : pcfPositions.keySet()) {
        final Collection<PCFPosition> chromosomePcfPositions = pcfPositions.get(chromosome);
        final List<CobaltRatio> chromosomeRatios = ratios.containsKey(chromosome) ? ratios.get(chromosome) : Lists.newArrayList();
        final Collection<SVSegment> chromosomeVariants =
                variantPositions.containsKey(chromosome) ? variantPositions.get(chromosome) : Lists.newArrayList();
        clusters.putAll(chromosome, cluster(chromosomeVariants, chromosomePcfPositions, chromosomeRatios));
    }

    return clusters;
}
 
源代码17 项目: dsl-devkit   文件: EClassComparator.java
/**
 * Returns a list sorted according to related groups of types.
 *
 * @param objects
 *          collection to sort
 * @param mapping
 *          mapping function
 * @param <T>
 *          object type
 * @return sorted list
 */
public static <T> ListMultimap<EPackage, T> sortedEPackageGroups(final Iterable<T> objects, final Function<T, EClass> mapping) {
  ListMultimap<EPackage, T> index = Multimaps.index(objects, new Function<T, EPackage>() {
    @Override
    public EPackage apply(final T from) {
      return mapping.apply(from).getEPackage();
    }
  });
  ListMultimap<EPackage, T> result = LinkedListMultimap.create(index.keySet().size());
  for (EPackage pkg : index.keySet()) {
    result.putAll(pkg, sortedGroups(index.get(pkg), mapping));
  }
  return result;
}
 
源代码18 项目: hmftools   文件: SageApplication.java
@NotNull
private static ListMultimap<Chromosome, GenomeRegion> readPanel(@NotNull final String panelBed) throws IOException {
    final ListMultimap<Chromosome, GenomeRegion> panel = ArrayListMultimap.create();
    if (!panelBed.isEmpty()) {
        LOGGER.info("Reading bed file: {}", panelBed);
        SortedSetMultimap<String, GenomeRegion> bed = BEDFileLoader.fromBedFile(panelBed);
        for (String contig : bed.keySet()) {
            if (HumanChromosome.contains(contig)) {
                panel.putAll(HumanChromosome.fromString(contig), bed.get(contig));
            }
        }
    }

    return panel;
}
 
源代码19 项目: NotEnoughItems   文件: ItemList.java
@Override
public void execute() {
    ThreadOperationTimer timer = getTimer(500);

    LinkedList<ItemStack> items = new LinkedList<>();
    LinkedList<ItemStack> permutations = new LinkedList<>();
    ListMultimap<Item, ItemStack> itemMap = ArrayListMultimap.create();

    timer.setLimit(500);
    for (Item item : Item.REGISTRY) {
        if (interrupted()) {
            return;
        }

        if (item == null || erroredItems.contains(item) || item == Items.AIR) {
            continue;
        }

        try {
            timer.reset(item);

            permutations.clear();
            permutations.addAll(ItemInfo.itemOverrides.get(item));

            if (permutations.isEmpty()) {
                item.getSubItems(CreativeTabs.SEARCH, new NonNullList<>(permutations, null));
            }

            //TODO, the implementation of damageSearch is wrong, not sure if this is actually needed ever.
            //if (permutations.isEmpty()) {
            //    damageSearch(item, permutations);
            //}

            permutations.addAll(ItemInfo.itemVariants.get(item));

            timer.reset();
            items.addAll(permutations);
            itemMap.putAll(item, permutations);
        } catch (Throwable t) {
            LogHelper.errorError("Removing item: %s from list.", t, item);
            erroredItems.add(item);
        }
    }

    if (interrupted()) {
        return;
    }
    ItemList.items = items;
    ItemList.itemMap = itemMap;
    synchronized (loadCallbacks) {
        for (ItemsLoadedCallback callback : loadCallbacks) {
            callback.itemsLoaded();
        }
    }

    updateFilter.restart();
}
 
源代码20 项目: sailfish-core   文件: AMLBlockProcessor.java
public static ListMultimap<AMLBlockType, AMLTestCase> process(ListMultimap<AMLBlockType, AMLTestCase> allBlocks, AMLSettings settings, IActionManager actionManager, Map<String, SortedMap<Long, String>> definedServiceNames)
        throws AMLException {
    AlertCollector alertCollector = new AlertCollector();

    List<AMLTestCase> testCases = allBlocks.get(AMLBlockType.TestCase);
    List<AMLTestCase> blocks = allBlocks.get(AMLBlockType.Block);
    List<AMLTestCase> beforeTCBlocks = allBlocks.get(AMLBlockType.BeforeTCBlock);
    List<AMLTestCase> afterTCBlocks = allBlocks.get(AMLBlockType.AfterTCBlock);
    List<AMLTestCase> firstBlocks = allBlocks.get(AMLBlockType.FirstBlock);
    List<AMLTestCase> lastBlocks = allBlocks.get(AMLBlockType.LastBlock);
    List<AMLTestCase> globalBlocks = allBlocks.get(AMLBlockType.GlobalBlock);

    retainExecutableTestCases(testCases, settings);

    if(testCases.isEmpty()) {
        alertCollector.add(new Alert("Nothing to execute"));
    }

    checkBlockReferences(testCases, alertCollector);
    checkBlockReferences(blocks, alertCollector);
    checkBlockReferences(beforeTCBlocks, alertCollector);
    checkBlockReferences(afterTCBlocks, alertCollector);

    insertGlobalBlocks(testCases, globalBlocks, alertCollector);
    insertFirstAndLastBlocks(testCases, firstBlocks, lastBlocks);

    Set<String> invalidBlockReferences = getRecursiveBlockReferences(blocks, alertCollector);

    insertIncludeBlocks(testCases, blocks, invalidBlockReferences, alertCollector, actionManager, definedServiceNames);
    insertIncludeBlocks(beforeTCBlocks, blocks, invalidBlockReferences, alertCollector, actionManager, definedServiceNames);
    insertIncludeBlocks(afterTCBlocks, blocks, invalidBlockReferences, alertCollector, actionManager, definedServiceNames);

    copyStaticActions(testCases, AMLLangConst.AML2.matches(settings.getLanguageURI()), alertCollector);
    setLastOutcomes(testCases);

    ListMultimap<AMLBlockType, AMLTestCase> processedBlocks = ArrayListMultimap.create();

    processedBlocks.putAll(AMLBlockType.TestCase, testCases);
    processedBlocks.putAll(AMLBlockType.BeforeTCBlock, beforeTCBlocks);
    processedBlocks.putAll(AMLBlockType.AfterTCBlock, afterTCBlocks);

    for(AMLTestCase testCase : allBlocks.values()) {
        for(AMLAction action : testCase.getActions()) {
            List<String> dependencies = action.getDependencies();

            if(dependencies.isEmpty()) {
                continue;
            }

            for(String dependency : dependencies) {
                AMLAction dependencyAction = testCase.findActionByRef(dependency);

                if(dependencyAction == null) {
                    String reference = ObjectUtils.defaultIfNull(action.getReference(), action.getReferenceToFilter());
                    alertCollector.add(new Alert(action.getLine(), reference, Column.Dependencies.getName(), "Dependency on unknown action: " + dependency));
                }

                if(dependencyAction == action) {
                    alertCollector.add(new Alert(action.getLine(), dependency, Column.Dependencies.getName(), "Action cannot depend on itself"));
                }
            }
        }
    }

    if(alertCollector.getCount(AlertType.ERROR) > 0) {
        throw new AMLException("Failed to process blocks", alertCollector);
    }

    return processedBlocks;
}