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


Java MultimapBuilder類代碼示例

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


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

示例1: parseEAConstraints

import com.google.common.collect.MultimapBuilder; //導入依賴的package包/類
/**
 * @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;
}
 
開發者ID:ShapeChange,項目名稱:ShapeChange,代碼行數:21,代碼來源:EAModelDiff.java

示例2: parseEAAttributeConstraints

import com.google.common.collect.MultimapBuilder; //導入依賴的package包/類
/**
 * @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;
}
 
開發者ID:ShapeChange,項目名稱:ShapeChange,代碼行數:21,代碼來源:EAModelDiff.java

示例3: parseEAConnectorConstraints

import com.google.common.collect.MultimapBuilder; //導入依賴的package包/類
/**
 * @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;
}
 
開發者ID:ShapeChange,項目名稱:ShapeChange,代碼行數:21,代碼來源:EAModelDiff.java

示例4: groupOperationsByTag

import com.google.common.collect.MultimapBuilder; //導入依賴的package包/類
/**
 * 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;
}
 
開發者ID:Swagger2Markup,項目名稱:swagger2markup,代碼行數:31,代碼來源:TagUtils.java

示例5: DatabaseCacheManager

import com.google.common.collect.MultimapBuilder; //導入依賴的package包/類
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<>();
}
 
開發者ID:PyvesB,項目名稱:AdvancedAchievements,代碼行數:19,代碼來源:DatabaseCacheManager.java

示例6: findCandidates

import com.google.common.collect.MultimapBuilder; //導入依賴的package包/類
@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;
}
 
開發者ID:jhendess,項目名稱:metadict,代碼行數:21,代碼來源:DictionaryObjectMerger.java

示例7: initChangeRefMaps

import com.google.common.collect.MultimapBuilder; //導入依賴的package包/類
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);
        }
      }
    }
  }
}
 
開發者ID:gerrit-review,項目名稱:gerrit,代碼行數:21,代碼來源:ReceiveCommits.java

示例8: onLoad

import com.google.common.collect.MultimapBuilder; //導入依賴的package包/類
@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);
}
 
開發者ID:gerrit-review,項目名稱:gerrit,代碼行數:22,代碼來源:RobotCommentNotes.java

示例9: NoteDbUpdateManager

import com.google.common.collect.MultimapBuilder; //導入依賴的package包/類
@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<>();
}
 
開發者ID:gerrit-review,項目名稱:gerrit,代碼行數:21,代碼來源:NoteDbUpdateManager.java

示例10: onLoad

import com.google.common.collect.MultimapBuilder; //導入依賴的package包/類
@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);
}
 
開發者ID:gerrit-review,項目名稱:gerrit,代碼行數:26,代碼來源:DraftCommentNotes.java

示例11: buildApprovals

import com.google.common.collect.MultimapBuilder; //導入依賴的package包/類
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;
}
 
開發者ID:gerrit-review,項目名稱:gerrit,代碼行數:18,代碼來源:ChangeNotesParser.java

示例12: getChangesByProject

import com.google.common.collect.MultimapBuilder; //導入依賴的package包/類
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);
}
 
開發者ID:gerrit-review,項目名稱:gerrit,代碼行數:17,代碼來源:NoteDbMigrator.java

示例13: sort

import com.google.common.collect.MultimapBuilder; //導入依賴的package包/類
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);
}
 
開發者ID:gerrit-review,項目名稱:gerrit,代碼行數:27,代碼來源:EventSorter.java

示例14: updateCache

import com.google.common.collect.MultimapBuilder; //導入依賴的package包/類
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();
  }
}
 
開發者ID:gerrit-review,項目名稱:gerrit,代碼行數:24,代碼來源:ExternalIdCacheImpl.java

示例15: intersection

import com.google.common.collect.MultimapBuilder; //導入依賴的package包/類
@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;
}
 
開發者ID:gerrit-review,項目名稱:gerrit,代碼行數:23,代碼來源:UniversalGroupBackend.java


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