本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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<>();
}
示例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;
}
示例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);
}
}
}
}
}
示例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);
}
示例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<>();
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}
示例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();
}
}
示例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;
}