Java 类com.google.common.collect.MultimapBuilder 实例源码

项目:ShapeChange    文件:EAModelDiff.java   
/**
 * @param cons
 * @return multimap of constraint infos, with constraint names as sorted
 *         keys, and constraints stored in an array list
 */
private ListMultimap<String, EAConstraintInfo> parseEAConstraints(
        Collection<Constraint> cons) {

    ListMultimap<String, EAConstraintInfo> result = MultimapBuilder
            .treeKeys().arrayListValues().build();

    for (short i = 0; i < cons.GetCount(); i++) {

        Constraint con = cons.GetAt(i);
        result.put(con.GetName(), new EAConstraintInfo(con.GetName(),
                con.GetType(), con.GetStatus(), con.GetNotes()));
    }

    return result;
}
项目:ShapeChange    文件:EAModelDiff.java   
/**
 * @param cons
 * @return multimap of constraint infos, with constraint names as sorted
 *         keys, and constraints stored in an array list
 */
private ListMultimap<String, EAConstraintInfo> parseEAAttributeConstraints(
        Collection<AttributeConstraint> cons) {

    ListMultimap<String, EAConstraintInfo> result = MultimapBuilder
            .treeKeys().arrayListValues().build();

    for (short i = 0; i < cons.GetCount(); i++) {

        AttributeConstraint con = cons.GetAt(i);
        result.put(con.GetName(), new EAConstraintInfo(con.GetName(),
                con.GetType(), "", con.GetNotes()));
    }

    return result;
}
项目:ShapeChange    文件:EAModelDiff.java   
/**
 * @param cons
 * @return multimap of constraint infos, with constraint names as sorted
 *         keys, and constraints stored in an array list
 */
private ListMultimap<String, EAConstraintInfo> parseEAConnectorConstraints(
        Collection<ConnectorConstraint> cons) {

    ListMultimap<String, EAConstraintInfo> result = MultimapBuilder
            .treeKeys().arrayListValues().build();

    for (short i = 0; i < cons.GetCount(); i++) {

        ConnectorConstraint con = cons.GetAt(i);
        result.put(con.GetName(), new EAConstraintInfo(con.GetName(),
                con.GetType(), "", con.GetNotes()));
    }

    return result;
}
项目:swagger2markup    文件:TagUtils.java   
/**
 * Groups the operations by tag. The key of the Multimap is the tag name.
 * The value of the Multimap is a PathOperation
 *
 * @param allOperations     all operations
 * @param operationOrdering comparator for operations, for a given tag
 * @return Operations grouped by Tag
 */
public static Multimap<String, PathOperation> groupOperationsByTag(List<PathOperation> allOperations, Comparator<PathOperation> operationOrdering) {

    Multimap<String, PathOperation> operationsGroupedByTag;
    if (operationOrdering == null) {
        operationsGroupedByTag = LinkedHashMultimap.create();
    } else {
        operationsGroupedByTag = MultimapBuilder.linkedHashKeys().treeSetValues(operationOrdering).build();
    }
    for (PathOperation operation : allOperations) {
        List<String> tags = operation.getOperation().getTags();

        Validate.notEmpty(tags, "Can't GroupBy.TAGS. Operation '%s' has no tags", operation);
        for (String tag : tags) {
            if (logger.isDebugEnabled()) {
                logger.debug("Added path operation '{}' to tag '{}'", operation, tag);
            }
            operationsGroupedByTag.put(tag, operation);
        }
    }

    return operationsGroupedByTag;
}
项目:AdvancedAchievements    文件:DatabaseCacheManager.java   
public DatabaseCacheManager(AdvancedAchievements plugin) {
    this.plugin = plugin;
    normalAchievementsToPlayerStatistics = new EnumMap<>(NormalAchievements.class);
    multipleAchievementsToPlayerStatistics = new EnumMap<>(MultipleAchievements.class);
    receivedAchievementsCache = MultimapBuilder.hashKeys().hashSetValues().build();
    notReceivedAchievementsCache = MultimapBuilder.hashKeys().hashSetValues().build();

    // ConcurrentHashMaps are necessary to guarantee thread safety.
    for (NormalAchievements normalAchievement : NormalAchievements.values()) {
        normalAchievementsToPlayerStatistics.put(normalAchievement,
                new ConcurrentHashMap<String, CachedStatistic>());
    }
    for (MultipleAchievements multipleAchievement : MultipleAchievements.values()) {
        multipleAchievementsToPlayerStatistics.put(multipleAchievement,
                new ConcurrentHashMap<String, CachedStatistic>());
    }
    totalPlayerAchievementsCache = new ConcurrentHashMap<>();
}
项目:metadict    文件:DictionaryObjectMerger.java   
@NotNull
@Override
protected Collection<Collection<DictionaryObject>> findCandidates(@NotNull Collection<DictionaryObject> normalizedInput) {
    Multimap<Pair<String, Language>, DictionaryObject> candidateMap = MultimapBuilder.hashKeys().linkedListValues().build();

    for (DictionaryObject dictionaryObject : normalizedInput) {
        Pair<String, Language> candidateIdentifier = ImmutablePair.of(
                CommonUtils.stripAndLowercase(dictionaryObject.getGeneralForm()),
                dictionaryObject.getLanguage()
        );
        candidateMap.put(candidateIdentifier, dictionaryObject);
    }

    Collection<Collection<DictionaryObject>> candidates = new ArrayList<>(candidateMap.keySet().size());
    for (Pair<String, Language> key : candidateMap.keySet()) {
        candidates.add(candidateMap.get(key));
    }

    return candidates;
}
项目:gerrit    文件:ReceiveCommits.java   
private void initChangeRefMaps() {
  if (refsByChange == null) {
    int estRefsPerChange = 4;
    refsById = MultimapBuilder.hashKeys().arrayListValues().build();
    refsByChange =
        MultimapBuilder.hashKeys(allRefs().size() / estRefsPerChange)
            .arrayListValues(estRefsPerChange)
            .build();
    for (Ref ref : allRefs().values()) {
      ObjectId obj = ref.getObjectId();
      if (obj != null) {
        PatchSet.Id psId = PatchSet.Id.fromRef(ref.getName());
        if (psId != null) {
          refsById.put(obj, ref);
          refsByChange.put(psId.getParentKey(), ref);
        }
      }
    }
  }
}
项目:gerrit    文件:RobotCommentNotes.java   
@Override
protected void onLoad(LoadHandle handle) throws IOException, ConfigInvalidException {
  metaId = handle.id();
  if (metaId == null) {
    loadDefaults();
    return;
  }
  metaId = metaId.copy();

  RevCommit tipCommit = handle.walk().parseCommit(metaId);
  ObjectReader reader = handle.walk().getObjectReader();
  revisionNoteMap =
      RevisionNoteMap.parseRobotComments(args.noteUtil, reader, NoteMap.read(reader, tipCommit));
  ListMultimap<RevId, RobotComment> cs = MultimapBuilder.hashKeys().arrayListValues().build();
  for (RobotCommentsRevisionNote rn : revisionNoteMap.revisionNotes.values()) {
    for (RobotComment c : rn.getComments()) {
      cs.put(new RevId(c.revId), c);
    }
  }
  comments = ImmutableListMultimap.copyOf(cs);
}
项目:gerrit    文件:NoteDbUpdateManager.java   
@Inject
NoteDbUpdateManager(
    @GerritPersonIdent Provider<PersonIdent> serverIdent,
    GitRepositoryManager repoManager,
    NotesMigration migration,
    AllUsersName allUsersName,
    NoteDbMetrics metrics,
    @Assisted Project.NameKey projectName) {
  this.serverIdent = serverIdent;
  this.repoManager = repoManager;
  this.migration = migration;
  this.allUsersName = allUsersName;
  this.metrics = metrics;
  this.projectName = projectName;
  changeUpdates = MultimapBuilder.hashKeys().arrayListValues().build();
  draftUpdates = MultimapBuilder.hashKeys().arrayListValues().build();
  robotCommentUpdates = MultimapBuilder.hashKeys().arrayListValues().build();
  rewriters = MultimapBuilder.hashKeys().arrayListValues().build();
  toDelete = new HashSet<>();
}
项目:gerrit    文件:DraftCommentNotes.java   
@Override
protected void onLoad(LoadHandle handle) throws IOException, ConfigInvalidException {
  ObjectId rev = handle.id();
  if (rev == null) {
    loadDefaults();
    return;
  }

  RevCommit tipCommit = handle.walk().parseCommit(rev);
  ObjectReader reader = handle.walk().getObjectReader();
  revisionNoteMap =
      RevisionNoteMap.parse(
          args.noteUtil,
          getChangeId(),
          reader,
          NoteMap.read(reader, tipCommit),
          PatchLineComment.Status.DRAFT);
  ListMultimap<RevId, Comment> cs = MultimapBuilder.hashKeys().arrayListValues().build();
  for (ChangeRevisionNote rn : revisionNoteMap.revisionNotes.values()) {
    for (Comment c : rn.getComments()) {
      cs.put(new RevId(c.revId), c);
    }
  }
  comments = ImmutableListMultimap.copyOf(cs);
}
项目:gerrit    文件:ChangeNotesParser.java   
private ListMultimap<PatchSet.Id, PatchSetApproval> buildApprovals() {
  ListMultimap<PatchSet.Id, PatchSetApproval> result =
      MultimapBuilder.hashKeys().arrayListValues().build();
  for (PatchSetApproval a : approvals.values()) {
    if (!patchSets.containsKey(a.getPatchSetId())) {
      continue; // Patch set deleted or missing.
    } else if (allPastReviewers.contains(a.getAccountId())
        && !reviewers.containsRow(a.getAccountId())) {
      continue; // Reviewer was explicitly removed.
    }
    result.put(a.getPatchSetId(), a);
  }
  for (Collection<PatchSetApproval> v : result.asMap().values()) {
    Collections.sort((List<PatchSetApproval>) v, ChangeNotes.PSA_BY_TIME);
  }
  return result;
}
项目:gerrit    文件:NoteDbMigrator.java   
private ImmutableListMultimap<Project.NameKey, Change.Id> getChangesByProject(ReviewDb db)
    throws OrmException {
  // Memoize all changes so we can close the db connection and allow other threads to use the full
  // connection pool.
  SetMultimap<Project.NameKey, Change.Id> out =
      MultimapBuilder.treeKeys(comparing(Project.NameKey::get))
          .treeSetValues(comparing(Change.Id::get))
          .build();
  if (!projects.isEmpty()) {
    return byProject(db.changes().all(), c -> projects.contains(c.getProject()), out);
  }
  if (!changes.isEmpty()) {
    return byProject(db.changes().get(changes), c -> true, out);
  }
  return byProject(db.changes().all(), c -> true, out);
}
项目:gerrit    文件:EventSorter.java   
void sort() {
  // First pass: sort by natural order.
  PriorityQueue<Event> todo = new PriorityQueue<>(out);

  // Populate waiting map after initial sort to preserve natural order.
  waiting = MultimapBuilder.hashKeys().arrayListValues().build();
  deps = MultimapBuilder.hashKeys().hashSetValues().build();
  for (Event e : todo) {
    for (Event d : e.deps) {
      deps.put(e, d);
      waiting.put(d, e);
    }
  }

  // Second pass: enforce dependencies.
  int size = out.size();
  while (!todo.isEmpty()) {
    process(todo.remove(), todo);
  }
  checkState(
      sorted.size() == size, "event sort expected %s elements, got %s", size, sorted.size());

  // Modify out in-place a la Collections#sort.
  out.clear();
  out.addAll(sorted);
}
项目:gerrit    文件:ExternalIdCacheImpl.java   
private void updateCache(
    ObjectId oldNotesRev,
    ObjectId newNotesRev,
    Consumer<Multimap<Account.Id, ExternalId>> update) {
  lock.lock();
  try {
    ListMultimap<Account.Id, ExternalId> m;
    if (!ObjectId.zeroId().equals(oldNotesRev)) {
      m =
          MultimapBuilder.hashKeys()
              .arrayListValues()
              .build(extIdsByAccount.get(oldNotesRev).byAccount());
    } else {
      m = MultimapBuilder.hashKeys().arrayListValues().build();
    }
    update.accept(m);
    extIdsByAccount.put(newNotesRev, AllExternalIds.create(m));
  } catch (ExecutionException e) {
    log.warn("Cannot update external IDs", e);
  } finally {
    lock.unlock();
  }
}
项目:gerrit    文件:UniversalGroupBackend.java   
@Override
public Set<AccountGroup.UUID> intersection(Iterable<AccountGroup.UUID> uuids) {
  ListMultimap<GroupMembership, AccountGroup.UUID> lookups =
      MultimapBuilder.hashKeys().arrayListValues().build();
  for (AccountGroup.UUID uuid : uuids) {
    if (uuid == null) {
      continue;
    }
    GroupMembership m = membership(uuid);
    if (m == null) {
      log.debug("Unknown GroupMembership for UUID: " + uuid);
      continue;
    }
    lookups.put(m, uuid);
  }
  Set<AccountGroup.UUID> groups = new HashSet<>();
  for (Map.Entry<GroupMembership, Collection<AccountGroup.UUID>> entry :
      lookups.asMap().entrySet()) {
    groups.addAll(entry.getKey().intersection(entry.getValue()));
  }
  return groups;
}
项目:gerrit    文件:TrackingFooters.java   
public ListMultimap<String, String> extract(List<FooterLine> lines) {
  ListMultimap<String, String> r = MultimapBuilder.hashKeys().arrayListValues().build();
  if (lines == null) {
    return r;
  }

  for (FooterLine footer : lines) {
    for (TrackingFooter config : trackingFooters) {
      if (footer.matches(config.footerKey())) {
        Matcher m = config.match().matcher(footer.getValue());
        while (m.find()) {
          String id = m.groupCount() > 0 ? m.group(1) : m.group();
          if (!id.isEmpty()) {
            r.put(config.system(), id);
          }
        }
      }
    }
  }
  return r;
}
项目:gerrit    文件:NotifyUtil.java   
public ListMultimap<RecipientType, Account.Id> resolveAccounts(
    @Nullable Map<RecipientType, NotifyInfo> notifyDetails)
    throws OrmException, BadRequestException, IOException, ConfigInvalidException {
  if (isNullOrEmpty(notifyDetails)) {
    return ImmutableListMultimap.of();
  }

  ListMultimap<RecipientType, Account.Id> m = null;
  for (Entry<RecipientType, NotifyInfo> e : notifyDetails.entrySet()) {
    List<String> accounts = e.getValue().accounts;
    if (accounts != null) {
      if (m == null) {
        m = MultimapBuilder.hashKeys().arrayListValues().build();
      }
      m.putAll(e.getKey(), find(accounts));
    }
  }

  return m != null ? m : ImmutableListMultimap.of();
}
项目:gerrit    文件:GetBlame.java   
private List<BlameInfo> blame(ObjectId id, String path, Repository repository, RevWalk revWalk)
    throws IOException {
  ListMultimap<BlameInfo, RangeInfo> ranges =
      MultimapBuilder.hashKeys().arrayListValues().build();
  List<BlameInfo> result = new ArrayList<>();
  if (blameCache.findLastCommit(repository, id, path) == null) {
    return result;
  }

  List<Region> blameRegions = blameCache.get(repository, id, path);
  int from = 1;
  for (Region region : blameRegions) {
    RevCommit commit = revWalk.parseCommit(region.getSourceCommit());
    BlameInfo blameInfo = toBlameInfo(commit, region.getSourceAuthor());
    ranges.put(blameInfo, new RangeInfo(from, from + region.getCount() - 1));
    from += region.getCount();
  }

  for (BlameInfo key : ranges.keySet()) {
    key.ranges = ranges.get(key);
    result.add(key);
  }
  return result;
}
项目:error-prone    文件:FutureReturnValueIgnored.java   
private static Multimap<TypeVariableSymbol, TypeInfo> getResolvedGenerics(
    MethodInvocationTree tree) {
  Type type = ASTHelpers.getType(tree.getMethodSelect());
  List<Type> from = new ArrayList<>();
  List<Type> to = new ArrayList<>();
  getSubst(type, from, to);
  Multimap<TypeVariableSymbol, TypeInfo> result =
      Streams.zip(
              from.stream(),
              to.stream(),
              (f, t) -> new TypeInfo((TypeVariableSymbol) f.asElement(), t, tree))
          .collect(
              toMultimap(
                  k -> k.sym, k -> k, MultimapBuilder.linkedHashKeys().arrayListValues()::build));
  return result;
}
项目:MCAnm    文件:ModelDescription.java   
private ImmutableMap<TransformType, TRSRTransformation> parseTransformObject(
        JsonDeserializationContext context,
        JsonObject viewObject) {
    ListMultimap<String, JsonElement> transformEntries = MultimapBuilder.hashKeys().arrayListValues(1).build();
    for (Map.Entry<String, JsonElement> entry : viewObject.entrySet()) {
        transformEntries.put(entry.getKey().toUpperCase(Locale.ROOT), entry.getValue());
    }

    ImmutableMap.Builder<TransformType, TRSRTransformation> result = ImmutableMap.builder();
    for (TransformType transformType : TransformType.values()) {
        String transformName = transformType.name().toUpperCase(Locale.ROOT);
        List<JsonElement> entryList = transformEntries.get(transformName);
        if (entryList.isEmpty()) {
            continue;
        }
        if (entryList.size() > 1) {
            throw new JsonParseException("Two transform entries for " + transformName);
        }
        JsonElement onlyElement = entryList.get(0);
        result.put(transformType, context.deserialize(onlyElement, TRSRTransformation.class));
    }
    return result.build();
}
项目:glowroot    文件:ClasspathCache.java   
synchronized void updateCache() {
    Multimap<String, Location> newClassNameLocations = HashMultimap.create();
    for (ClassLoader loader : getKnownClassLoaders()) {
        updateCache(loader, newClassNameLocations);
    }
    updateCacheWithClasspathClasses(newClassNameLocations);
    updateCacheWithBootstrapClasses(newClassNameLocations);
    if (!newClassNameLocations.isEmpty()) {
        // multimap that sorts keys and de-dups values while maintains value ordering
        SetMultimap<String, Location> newMap =
                MultimapBuilder.treeKeys().linkedHashSetValues().build();
        newMap.putAll(classNameLocations);
        newMap.putAll(newClassNameLocations);
        classNameLocations = ImmutableMultimap.copyOf(newMap);
    }
}
项目:bazel    文件:TestSummary.java   
private void mergeFrom(TestSummary existingSummary) {
  // Yuck, manually fill in fields.
  summary.shardRunStatuses =
      MultimapBuilder.hashKeys().arrayListValues().build(existingSummary.shardRunStatuses);
  setTarget(existingSummary.target);
  setStatus(existingSummary.status);
  addCoverageFiles(existingSummary.coverageFiles);
  addPassedLogs(existingSummary.passedLogs);
  addFailedLogs(existingSummary.failedLogs);

  if (existingSummary.failedTestCasesStatus != null) {
    addFailedTestCases(existingSummary.getFailedTestCases(),
        existingSummary.getFailedTestCasesStatus());
  }

  addTestTimes(existingSummary.testTimes);
  addWarnings(existingSummary.warnings);
  setActionRan(existingSummary.actionRan);
  setNumCached(existingSummary.numCached);
  setRanRemotely(existingSummary.ranRemotely);
  setWasUnreportedWrongSize(existingSummary.wasUnreportedWrongSize);
}
项目:buck    文件:VFSOverlay.java   
@JsonProperty("roots")
private ImmutableList<VirtualDirectory> computeRoots() {
  Multimap<Path, Pair<Path, Path>> byParent = MultimapBuilder.hashKeys().hashSetValues().build();
  overlays.forEach(
      (virtual, real) -> {
        byParent.put(virtual.getParent(), new Pair<>(virtual.getFileName(), real));
      });
  return byParent
      .asMap()
      .entrySet()
      .stream()
      .map(
          e ->
              new VirtualDirectory(
                  e.getKey(),
                  e.getValue()
                      .stream()
                      .map(x -> new VirtualFile(x.getFirst(), x.getSecond()))
                      .collect(ImmutableList.toImmutableList())))
      .collect(ImmutableList.toImmutableList());
}
项目:buck    文件:APKModuleGraph.java   
/**
 * For each seed target, find its reachable targets and mark them in a multimap as being reachable
 * by that module for later sorting into exclusive and shared targets
 *
 * @return the Multimap containing targets and the seed modules that contain them
 */
private Multimap<BuildTarget, String> mapTargetsToContainingModules() {
  final Multimap<BuildTarget, String> targetToContainingApkModuleNameMap =
      MultimapBuilder.treeKeys().treeSetValues().build();
  for (Map.Entry<String, List<BuildTarget>> seedConfig : getSeedConfigMap().get().entrySet()) {
    final String seedModuleName = seedConfig.getKey();
    for (BuildTarget seedTarget : seedConfig.getValue()) {
      targetToContainingApkModuleNameMap.put(seedTarget, seedModuleName);
      new AbstractBreadthFirstTraversal<TargetNode<?, ?>>(targetGraph.get(seedTarget)) {
        @Override
        public ImmutableSet<TargetNode<?, ?>> visit(TargetNode<?, ?> node) {

          ImmutableSet.Builder<TargetNode<?, ?>> depsBuilder = ImmutableSet.builder();
          for (BuildTarget depTarget : node.getBuildDeps()) {
            if (!isInRootModule(depTarget) && !isSeedTarget(depTarget)) {
              depsBuilder.add(targetGraph.get(depTarget));
              targetToContainingApkModuleNameMap.put(depTarget, seedModuleName);
            }
          }
          return depsBuilder.build();
        }
      }.start();
    }
  }
  return targetToContainingApkModuleNameMap;
}
项目:sentry    文件:PlayerCountService.java   
@Scheduled(cron = "10 * * * * ?")
void storePlayerCountMetrics() {
    ZonedDateTime timestamp = ZonedDateTime.now().truncatedTo(MINUTES);

    Map<String, AtomicLong> aggregations = new ConcurrentHashMap<>();

    metricRegistry.getGauges((name, metric) -> name.startsWith("UGC.GameServer.player_count"))
        .entrySet().stream()
        // all servers -> group into regions
        .collect(toMultimap(
            entry -> extractRegion(entry.getKey()),
            Map.Entry::getValue,
            MultimapBuilder.treeKeys().arrayListValues()::build))
        .entries()
        .forEach(entry -> aggregations.computeIfAbsent(entry.getKey(), k -> new AtomicLong())
            .addAndGet((Integer) entry.getValue().getValue()));

    aggregations.entrySet().stream()
        .filter(entry -> entry.getValue().get() > 0 || lastValueMap.getOrDefault(entry.getKey(), 0L) != 0)
        .forEach(entry -> {
            String region = entry.getKey();
            Long value = entry.getValue().get();
            if (lastValueMap.getOrDefault(entry.getKey(), 0L) == 0) {
                if (playerCountRepository.countByRegionAndValueAndTimestamp(region, value, timestamp) == 0) {
                    // add a 0 to the previous minute
                    playerCountRepository.save(new PlayerCount()
                        .timestamp(timestamp.minusMinutes(1))
                        .region(region)
                        .value(0L));
                }
            }
            playerCountRepository.save(new PlayerCount()
                .timestamp(timestamp)
                .region(region)
                .value(value));
            lastValueMap.put(region, value);
        });
}
项目:sentry    文件:ChartUtil.java   
public static <T> List<Series> getSeriesFromData(List<T> counts,
                                                 Function<T, String> seriesMapper,
                                                 Function<T, ZonedDateTime> timeMapper,
                                                 Function<T, Long> valueMapper) {
    // create a map of categories to x-y pairs
    Multimap<String, Point> byRegion = counts.stream()
        .collect(toMultimap(
            seriesMapper,
            count -> new Point(timeMapper.apply(count).toEpochSecond() * 1000, valueMapper.apply(count)),
            MultimapBuilder.treeKeys().hashSetValues()::build));
    // build a list of default values x-0 for each category
    Set<Long> timestamps = counts.stream()
        .map(count -> timeMapper.apply(count).toEpochSecond())
        .collect(Collectors.toSet());
    Multimap<String, Point> defaults = byRegion.keySet().stream()
        .collect(flatteningToMultimap(
            region -> region,
            region -> timestamps.stream().map(timestamp -> new Point(timestamp * 1000, 0)),
            MultimapBuilder.treeKeys().hashSetValues()::build));
    byRegion.putAll(defaults);
    log.debug("{} across {} found",
        inflect(byRegion.size(), "data point"), inflect(timestamps.size(), "timestamp"));
    // convert to expected structure
    return byRegion.asMap().entrySet().stream()
        .map(entry -> new Series(entry.getKey()).values(
            entry.getValue().stream()
                .map(pair -> Arrays.asList(pair.getX(), pair.getY()))
                .sorted(Comparator.comparingInt(o -> o.get(0).intValue()))
                .collect(Collectors.toList())))
        .collect(Collectors.toList());
}
项目:creacoinj    文件:PaymentChannelV2ClientState.java   
@Override
protected Multimap<State, State> getStateTransitions() {
    Multimap<State, State> result = MultimapBuilder.enumKeys(State.class).arrayListValues().build();
    result.put(State.UNINITIALISED, State.NEW);
    result.put(State.UNINITIALISED, State.READY);
    result.put(State.NEW, State.SAVE_STATE_IN_WALLET);
    result.put(State.SAVE_STATE_IN_WALLET, State.PROVIDE_MULTISIG_CONTRACT_TO_SERVER);
    result.put(State.PROVIDE_MULTISIG_CONTRACT_TO_SERVER, State.READY);
    result.put(State.READY, State.EXPIRED);
    result.put(State.READY, State.CLOSED);
    return result;
}
项目:creacoinj    文件:PaymentChannelV2ServerState.java   
@Override
public Multimap<State, State> getStateTransitions() {
    Multimap<State, State> result = MultimapBuilder.enumKeys(State.class).arrayListValues().build();
    result.put(State.UNINITIALISED, State.READY);
    result.put(State.UNINITIALISED, State.WAITING_FOR_MULTISIG_CONTRACT);
    result.put(State.WAITING_FOR_MULTISIG_CONTRACT, State.WAITING_FOR_MULTISIG_ACCEPTANCE);
    result.put(State.WAITING_FOR_MULTISIG_ACCEPTANCE, State.READY);
    result.put(State.READY, State.CLOSING);
    result.put(State.CLOSING, State.CLOSED);
    for (State state : State.values()) {
        result.put(state, State.ERROR);
    }
    return result;
}
项目:creacoinj    文件:PaymentChannelV1ClientState.java   
@Override
protected Multimap<State, State> getStateTransitions() {
    Multimap<State, State> result = MultimapBuilder.enumKeys(State.class).arrayListValues().build();
    result.put(State.UNINITIALISED, State.NEW);
    result.put(State.UNINITIALISED, State.READY);
    result.put(State.NEW, State.INITIATED);
    result.put(State.INITIATED, State.WAITING_FOR_SIGNED_REFUND);
    result.put(State.WAITING_FOR_SIGNED_REFUND, State.SAVE_STATE_IN_WALLET);
    result.put(State.SAVE_STATE_IN_WALLET, State.PROVIDE_MULTISIG_CONTRACT_TO_SERVER);
    result.put(State.PROVIDE_MULTISIG_CONTRACT_TO_SERVER, State.READY);
    result.put(State.READY, State.EXPIRED);
    result.put(State.READY, State.CLOSED);
    return result;
}
项目:Elasticsearch    文件:SearchContext.java   
/**
 * Schedule the release of a resource. The time when {@link Releasable#close()} will be called on this object
 * is function of the provided {@link Lifetime}.
 */
public void addReleasable(Releasable releasable, Lifetime lifetime) {
    if (clearables == null) {
        clearables = MultimapBuilder.enumKeys(Lifetime.class).arrayListValues().build();
    }
    clearables.put(lifetime, releasable);
}
项目:okwallet    文件:PaymentChannelV2ClientState.java   
@Override
protected Multimap<State, State> getStateTransitions() {
    Multimap<State, State> result = MultimapBuilder.enumKeys(State.class).arrayListValues().build();
    result.put(State.UNINITIALISED, State.NEW);
    result.put(State.UNINITIALISED, State.READY);
    result.put(State.NEW, State.SAVE_STATE_IN_WALLET);
    result.put(State.SAVE_STATE_IN_WALLET, State.PROVIDE_MULTISIG_CONTRACT_TO_SERVER);
    result.put(State.PROVIDE_MULTISIG_CONTRACT_TO_SERVER, State.READY);
    result.put(State.READY, State.EXPIRED);
    result.put(State.READY, State.CLOSED);
    return result;
}
项目:okwallet    文件:PaymentChannelV2ServerState.java   
@Override
public Multimap<State, State> getStateTransitions() {
    Multimap<State, State> result = MultimapBuilder.enumKeys(State.class).arrayListValues().build();
    result.put(State.UNINITIALISED, State.READY);
    result.put(State.UNINITIALISED, State.WAITING_FOR_MULTISIG_CONTRACT);
    result.put(State.WAITING_FOR_MULTISIG_CONTRACT, State.WAITING_FOR_MULTISIG_ACCEPTANCE);
    result.put(State.WAITING_FOR_MULTISIG_ACCEPTANCE, State.READY);
    result.put(State.READY, State.CLOSING);
    result.put(State.CLOSING, State.CLOSED);
    for (State state : State.values()) {
        result.put(state, State.ERROR);
    }
    return result;
}
项目:okwallet    文件:PaymentChannelV1ClientState.java   
@Override
protected Multimap<State, State> getStateTransitions() {
    Multimap<State, State> result = MultimapBuilder.enumKeys(State.class).arrayListValues().build();
    result.put(State.UNINITIALISED, State.NEW);
    result.put(State.UNINITIALISED, State.READY);
    result.put(State.NEW, State.INITIATED);
    result.put(State.INITIATED, State.WAITING_FOR_SIGNED_REFUND);
    result.put(State.WAITING_FOR_SIGNED_REFUND, State.SAVE_STATE_IN_WALLET);
    result.put(State.SAVE_STATE_IN_WALLET, State.PROVIDE_MULTISIG_CONTRACT_TO_SERVER);
    result.put(State.PROVIDE_MULTISIG_CONTRACT_TO_SERVER, State.READY);
    result.put(State.READY, State.EXPIRED);
    result.put(State.READY, State.CLOSED);
    return result;
}
项目:vaadin-vertx-samples    文件:DummyDataProvider.java   
private Multimap<Long, MovieRevenue> countRevenues() {
    Multimap<Long, MovieRevenue> result = MultimapBuilder.hashKeys()
            .arrayListValues().build();
    for (Movie movie : movies) {
        result.putAll(movie.getId(), countMovieRevenue(movie));
    }
    return result;
}
项目:sentry    文件:PlayerCountService.java   
@Scheduled(cron = "10 * * * * ?")
void storePlayerCountMetrics() {
    ZonedDateTime timestamp = ZonedDateTime.now().truncatedTo(MINUTES);

    Map<String, AtomicLong> aggregations = new ConcurrentHashMap<>();

    metricRegistry.getGauges((name, metric) -> name.startsWith("UGC.GameServer.player_count"))
        .entrySet().stream()
        // all servers -> group into regions
        .collect(toMultimap(
            entry -> extractRegion(entry.getKey()),
            Map.Entry::getValue,
            MultimapBuilder.treeKeys().arrayListValues()::build))
        .entries()
        .forEach(entry -> aggregations.computeIfAbsent(entry.getKey(), k -> new AtomicLong())
            .addAndGet((Integer) entry.getValue().getValue()));

    aggregations.entrySet().stream()
        .filter(entry -> entry.getValue().get() > 0 || lastValueMap.getOrDefault(entry.getKey(), 0L) != 0)
        .forEach(entry -> {
            String region = entry.getKey();
            Long value = entry.getValue().get();
            if (lastValueMap.getOrDefault(entry.getKey(), 0L) == 0) {
                if (playerCountRepository.countByRegionAndValueAndTimestamp(region, value, timestamp) == 0) {
                    // add a 0 to the previous minute
                    playerCountRepository.save(new PlayerCount()
                        .timestamp(timestamp.minusMinutes(1))
                        .region(region)
                        .value(0L));
                }
            }
            playerCountRepository.save(new PlayerCount()
                .timestamp(timestamp)
                .region(region)
                .value(value));
            lastValueMap.put(region, value);
        });
}
项目:sentry    文件:ChartUtil.java   
public static <T> List<Series> getSeriesFromData(List<T> counts,
                                                 Function<T, String> seriesMapper,
                                                 Function<T, ZonedDateTime> timeMapper,
                                                 Function<T, Long> valueMapper) {
    // create a map of categories to x-y pairs
    Multimap<String, Point> byRegion = counts.stream()
        .collect(toMultimap(
            seriesMapper,
            count -> new Point(timeMapper.apply(count).toEpochSecond() * 1000, valueMapper.apply(count)),
            MultimapBuilder.treeKeys().hashSetValues()::build));
    // build a list of default values x-0 for each category
    Set<Long> timestamps = counts.stream()
        .map(count -> timeMapper.apply(count).toEpochSecond())
        .collect(Collectors.toSet());
    Multimap<String, Point> defaults = byRegion.keySet().stream()
        .collect(flatteningToMultimap(
            region -> region,
            region -> timestamps.stream().map(timestamp -> new Point(timestamp * 1000, 0)),
            MultimapBuilder.treeKeys().hashSetValues()::build));
    byRegion.putAll(defaults);
    log.debug("{} across {} found",
        inflect(byRegion.size(), "data point"), inflect(timestamps.size(), "timestamp"));
    // convert to expected structure
    return byRegion.asMap().entrySet().stream()
        .map(entry -> new Series(entry.getKey()).values(
            entry.getValue().stream()
                .map(pair -> Arrays.asList(pair.getX(), pair.getY()))
                .sorted(Comparator.comparingInt(o -> o.get(0).intValue()))
                .collect(Collectors.toList())))
        .collect(Collectors.toList());
}
项目:cryptwallet    文件:PaymentChannelV2ClientState.java   
@Override
protected Multimap<State, State> getStateTransitions() {
    Multimap<State, State> result = MultimapBuilder.enumKeys(State.class).arrayListValues().build();
    result.put(State.UNINITIALISED, State.NEW);
    result.put(State.UNINITIALISED, State.READY);
    result.put(State.NEW, State.SAVE_STATE_IN_WALLET);
    result.put(State.SAVE_STATE_IN_WALLET, State.PROVIDE_MULTISIG_CONTRACT_TO_SERVER);
    result.put(State.PROVIDE_MULTISIG_CONTRACT_TO_SERVER, State.READY);
    result.put(State.READY, State.EXPIRED);
    result.put(State.READY, State.CLOSED);
    return result;
}
项目:cryptwallet    文件:PaymentChannelV2ServerState.java   
@Override
public Multimap<State, State> getStateTransitions() {
    Multimap<State, State> result = MultimapBuilder.enumKeys(State.class).arrayListValues().build();
    result.put(State.UNINITIALISED, State.READY);
    result.put(State.UNINITIALISED, State.WAITING_FOR_MULTISIG_CONTRACT);
    result.put(State.WAITING_FOR_MULTISIG_CONTRACT, State.WAITING_FOR_MULTISIG_ACCEPTANCE);
    result.put(State.WAITING_FOR_MULTISIG_ACCEPTANCE, State.READY);
    result.put(State.READY, State.CLOSING);
    result.put(State.CLOSING, State.CLOSED);
    for (State state : State.values()) {
        result.put(state, State.ERROR);
    }
    return result;
}
项目:cryptwallet    文件:PaymentChannelV1ClientState.java   
@Override
protected Multimap<State, State> getStateTransitions() {
    Multimap<State, State> result = MultimapBuilder.enumKeys(State.class).arrayListValues().build();
    result.put(State.UNINITIALISED, State.NEW);
    result.put(State.UNINITIALISED, State.READY);
    result.put(State.NEW, State.INITIATED);
    result.put(State.INITIATED, State.WAITING_FOR_SIGNED_REFUND);
    result.put(State.WAITING_FOR_SIGNED_REFUND, State.SAVE_STATE_IN_WALLET);
    result.put(State.SAVE_STATE_IN_WALLET, State.PROVIDE_MULTISIG_CONTRACT_TO_SERVER);
    result.put(State.PROVIDE_MULTISIG_CONTRACT_TO_SERVER, State.READY);
    result.put(State.READY, State.EXPIRED);
    result.put(State.READY, State.CLOSED);
    return result;
}
项目:copybara    文件:TemplateTokens.java   
public TemplateTokens(Location location, String template, Map<String, Pattern> regexGroups,
    boolean repeatedGroups) throws EvalException {
  this.location = location;
  this.template = Preconditions.checkNotNull(template);

  Builder builder = new Builder();
  builder.location = location;
  builder.parse(template);
  this.before = builder.buildBefore(regexGroups, repeatedGroups);
  this.groupIndexes = MultimapBuilder.hashKeys().arrayListValues().build(builder.groupIndexes);
  this.tokens = ImmutableList.copyOf(builder.tokens);
  this.unusedGroups = Sets.difference(regexGroups.keySet(), groupIndexes.keySet());
}