本文整理汇总了Java中com.google.common.collect.Multimap.get方法的典型用法代码示例。如果您正苦于以下问题:Java Multimap.get方法的具体用法?Java Multimap.get怎么用?Java Multimap.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.common.collect.Multimap
的用法示例。
在下文中一共展示了Multimap.get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: corrigeerIdentiteitrecordsMetVervallenStandaard
import com.google.common.collect.Multimap; //导入方法依赖的package包/类
private void corrigeerIdentiteitrecordsMetVervallenStandaard(final Multimap<MetaObject, MetaRecord> records) {
final HashSet<MetaObject> copySet = Sets.newHashSet(records.keySet());
for (MetaObject metaObject : copySet) {
boolean heeftIdentiteitGroepZonderHistorie = metaObject.getObjectElement().getGroepen().stream().anyMatch(groepElement ->
groepElement.isIdentiteitGroep() && groepElement.getHistoriePatroon() == HistoriePatroon.G);
boolean heeftStandaardGroepMetHistorie = metaObject.getObjectElement().getGroepen().stream().anyMatch(groepElement ->
groepElement.isStandaardGroep() && groepElement.getHistoriePatroon() != HistoriePatroon.G);
if (heeftIdentiteitGroepZonderHistorie && heeftStandaardGroepMetHistorie) {
//is er een actueel standaard record
final Collection<MetaRecord> recordsVanObject = records.get(metaObject);
boolean actueelStandaardRecord = recordsVanObject.stream().anyMatch(metaRecord -> metaRecord.getParentGroep().getGroepElement()
.isStandaardGroep());
if (!actueelStandaardRecord) {
records.removeAll(metaObject);
}
}
}
}
示例2: sortByListSize
import com.google.common.collect.Multimap; //导入方法依赖的package包/类
/** Sorts a {@link Multimap} based on the length of each value list */
static public <E extends Comparable<E>, T extends Comparable<T>> TreeMap<T, Collection<E>> sortByListSize(
Multimap<T, E> multimap) {
Comparator<T> comparator = new Comparator<T>() {
@Override
public int compare(T t1, T t2) {
int s1 = multimap.get(t1).size();
int s2 = multimap.get(t2).size();
if (s2 != s1)
return s2 - s1;
return t1.compareTo(t2);
}
};
TreeMap<T, Collection<E>> sortedMap = new TreeMap<>(comparator);
for (T key : multimap.keySet()) {
Collection<E> elems = multimap.get(key);
sortedMap.put(key, elems);
}
return sortedMap;
}
示例3: createOptions
import com.google.common.collect.Multimap; //导入方法依赖的package包/类
/**
* Turn this Multimap into a two-dimensional array the first index giving the page, second the choices of this page.
*
* @param multimap
* name to many options
* @return two-dim Array of T
*/
public static <T> Object[][] createOptions(Multimap<String, T> multimap) {
Object[][] result = new Object[multimap.keySet().size()][];
int page = 0;
for (String key : multimap.keySet()) {
Collection<T> values = multimap.get(key);
result[page] = new Object[values.size()];
int valueIndex = 0;
for (T value : values) {
result[page][valueIndex] = value;
valueIndex++;
}
page++;
}
return result;
}
示例4: computeBuildOrderDepthFirst
import com.google.common.collect.Multimap; //导入方法依赖的package包/类
/**
* Recursive part of {@link #computeBuildOrderDepthFirst(Map, Multimap, Multimap, Collection)}. If all dependencies
* of the given project have already been processed, it is added to the build order. Then, all projects that depend
* on the given project are processed recursively.
*
* @param project
* the project to process
* @param markedProjects
* the marked projects
* @param pendencies
* maps projects to the projects that depend on them
* @param dependencies
* maps projects to the projects they depend on
* @param result
* the build order being computed
*/
private static void computeBuildOrderDepthFirst(IN4JSProject project,
Map<IN4JSProject, MarkedProject> markedProjects, Multimap<IN4JSProject, IN4JSProject> pendencies,
Multimap<IN4JSProject, IN4JSProject> dependencies, List<MarkedProject> result) {
// once all dependencies of the current project have been processed, we can add it to the build and
// process its children.
if (dependencies.get(project).isEmpty()) {
// The current project is ready to be processed.
result.add(markedProjects.get(project));
// Remove this project from the dependencies of all pending projects.
for (IN4JSProject dependentProject : pendencies.get(project)) {
dependencies.get(dependentProject).remove(project);
// Now process the pending project itself.
computeBuildOrderDepthFirst(dependentProject, markedProjects, pendencies, dependencies, result);
}
}
}
示例5: addToResultsTopDown
import com.google.common.collect.Multimap; //导入方法依赖的package包/类
private void addToResultsTopDown(Multimap<Long, T> parent2Nodes, Long parentId)
{
if( !parent2Nodes.containsKey(parentId) )
{
return;
}
Collection<T> nodes = parent2Nodes.get(parentId);
results.addAll(nodes);
for( T node : nodes )
{
// Recurse on child nodes
addToResultsTopDown(parent2Nodes, node.getId());
}
}
示例6: canonicalizeResponseSet
import com.google.common.collect.Multimap; //导入方法依赖的package包/类
/**
* Maps a {@code Set<Response>} to a {@code Set<TypeRoleFillerRealis>} which is supported by
* exactly the same responses. If any response supporting a TRFR is present in {@code
* responseGroup}, that TRFR will appear in the returned set. However, if such a TRFR is supported
* by responses but within and outside {@code responseSet}, an {@link
* java.lang.IllegalArgumentException} is thrown.
*/
private static ImmutableSet<TypeRoleFillerRealis> canonicalizeResponseSet(
Set<Response> responseGroup,
Multimap<TypeRoleFillerRealis, Response> canonicalToResponses,
Multimap<Response, TypeRoleFillerRealis> responsesToCanonical)
throws InconsistentLinkingException {
final ImmutableSet.Builder<TypeRoleFillerRealis> canonicalizationsWithResponsesInGroupBuilder =
ImmutableSet.builder();
for (final Response response : responseGroup) {
for (final TypeRoleFillerRealis canonicalization : responsesToCanonical.get(response)) {
canonicalizationsWithResponsesInGroupBuilder.add(canonicalization);
}
}
return canonicalizationsWithResponsesInGroupBuilder.build();
}
示例7: replaceModifier
import com.google.common.collect.Multimap; //导入方法依赖的package包/类
/**
* Replace a modifier in the {@link Multimap} with a copy that's had {@code multiplier} applied to its value.
*
* @param modifierMultimap The MultiMap
* @param attribute The attribute being modified
* @param id The ID of the modifier
* @param multiplier The multiplier to apply
*/
private void replaceModifier(Multimap<String, AttributeModifier> modifierMultimap, IAttribute attribute, UUID id, double multiplier)
{
// Get the modifiers for the specified attribute
final Collection<AttributeModifier> modifiers = modifierMultimap.get(attribute.getName());
// Find the modifier with the specified ID, if any
final Optional<AttributeModifier> modifierOptional = modifiers.stream().filter(attributeModifier -> attributeModifier.getID().equals(id)).findFirst();
if (modifierOptional.isPresent()) // If it exists,
{
final AttributeModifier modifier = modifierOptional.get();
modifiers.remove(modifier); // Remove it
modifiers.add(new AttributeModifier(modifier.getID(), modifier.getName(), modifier.getAmount() * multiplier, modifier.getOperation())); // Add the new modifier
}
}
示例8: logSummaryOfDuplicates
import com.google.common.collect.Multimap; //导入方法依赖的package包/类
private void logSummaryOfDuplicates( Multimap<Collection<File>, String> overlapping )
{
for ( Collection<File> jarz : overlapping.keySet() )
{
List<String> jarzS = new LinkedList<String>();
for ( File jjar : jarz )
{
jarzS.add( jjar.getName() );
}
List<String> classes = new LinkedList<String>();
for ( String clazz : overlapping.get( jarz ) )
{
classes.add( clazz.replace( ".class", "" ).replace( "/", "." ) );
}
//CHECKSTYLE_OFF: LineLength
getLogger().warn(
Joiner.on( ", " ).join( jarzS ) + " define " + classes.size() + " overlapping classes: " );
//CHECKSTYLE_ON: LineLength
int max = 10;
for ( int i = 0; i < Math.min( max, classes.size() ); i++ )
{
getLogger().warn( " - " + classes.get( i ) );
}
if ( classes.size() > max )
{
getLogger().warn( " - " + ( classes.size() - max ) + " more..." );
}
}
}
示例9: getApolloConfigNotifications
import com.google.common.collect.Multimap; //导入方法依赖的package包/类
private List<ApolloConfigNotification> getApolloConfigNotifications(Set<String> namespaces,
Map<String, Long> clientSideNotifications,
Multimap<String, String> watchedKeysMap,
List<ReleaseMessage> latestReleaseMessages) {
List<ApolloConfigNotification> newNotifications = Lists.newArrayList();
if (!CollectionUtils.isEmpty(latestReleaseMessages)) {
Map<String, Long> latestNotifications = Maps.newHashMap();
for (ReleaseMessage releaseMessage : latestReleaseMessages) {
latestNotifications.put(releaseMessage.getMessage(), releaseMessage.getId());
}
for (String namespace : namespaces) {
long clientSideId = clientSideNotifications.get(namespace);
long latestId = ConfigConsts.NOTIFICATION_ID_PLACEHOLDER;
Collection<String> namespaceWatchedKeys = watchedKeysMap.get(namespace);
for (String namespaceWatchedKey : namespaceWatchedKeys) {
long namespaceNotificationId =
latestNotifications.getOrDefault(namespaceWatchedKey, ConfigConsts.NOTIFICATION_ID_PLACEHOLDER);
if (namespaceNotificationId > latestId) {
latestId = namespaceNotificationId;
}
}
if (latestId > clientSideId) {
ApolloConfigNotification notification = new ApolloConfigNotification(namespace, latestId);
namespaceWatchedKeys.stream().filter(latestNotifications::containsKey).forEach(namespaceWatchedKey ->
notification.addMessage(namespaceWatchedKey, latestNotifications.get(namespaceWatchedKey)));
newNotifications.add(notification);
}
}
}
return newNotifications;
}
示例10: translateColumnName
import com.google.common.collect.Multimap; //导入方法依赖的package包/类
/**
* 根据名字在manager配置的映射关系,转化为目标的字段名字
*/
private String translateColumnName(String srcColumnName, DataMediaPair dataMediaPair,
Multimap<String, String> translateDict) {
if (dataMediaPair.getColumnPairMode().isExclude() || CollectionUtils.isEmpty(dataMediaPair.getColumnPairs())) {
return srcColumnName; // 默认同名
}
Collection<String> tColumnNames = translateDict.get(srcColumnName);
if (CollectionUtils.isEmpty(tColumnNames)) {
throw new TransformException(srcColumnName + " is not found in column pairs: " + translateDict.toString());
}
String columnName = tColumnNames.iterator().next();
return columnName;
}
示例11: buildWebhookDetails
import com.google.common.collect.Multimap; //导入方法依赖的package包/类
/***
* 构建WebhookDetail信息
*
* @param webhooks
* @param eventParams
* @param requestParams
* @return
*/
private List<WebhookDetail> buildWebhookDetails(List<Webhook> webhooks, List<WebhookEventParam> eventParams, List<WebhookRequestParam> requestParams) {
Multimap<Integer, WebhookEventParam> eventParamMultimap = ArrayListMultimap.create();
Multimap<Integer, WebhookRequestParam> requestParamMultimap = ArrayListMultimap.create();
if (CollectionUtils.isNotEmpty(eventParams)) {
for (WebhookEventParam eventParam : eventParams) {
eventParamMultimap.put(eventParam.getWebhookId(), eventParam);
}
}
if (CollectionUtils.isNotEmpty(requestParams)) {
for (WebhookRequestParam requestParam : requestParams) {
requestParamMultimap.put(requestParam.getWebhookId(), requestParam);
}
}
List<WebhookDetail> webhookDetails = new ArrayList<>();
if (CollectionUtils.isNotEmpty(webhooks)) {
for (Webhook webhook : webhooks) {
Collection<WebhookEventParam> webhookEventParams = eventParamMultimap.get(webhook.getId());
Collection<WebhookRequestParam> webhookRequestParams = requestParamMultimap.get(webhook.getId());
WebhookDetail webhookDetail = new WebhookDetail(webhook, webhookEventParams, webhookRequestParams);
webhookDetails.add(webhookDetail);
}
}
return webhookDetails;
}
示例12: replaceModifier
import com.google.common.collect.Multimap; //导入方法依赖的package包/类
private void replaceModifier(Multimap<String, AttributeModifier> modifierMultimap, IAttribute attribute, UUID id, double multiplier) {
final Collection<AttributeModifier> modifiers = modifierMultimap.get(attribute.getName());
final Optional<AttributeModifier> modifierOptional = modifiers.stream().filter(attributeModifier -> attributeModifier.getID().equals(id)).findFirst();
if (modifierOptional.isPresent()) {
final AttributeModifier modifier = modifierOptional.get();
modifiers.remove(modifier);
modifiers.add(new AttributeModifier(modifier.getID(), modifier.getName(), modifier.getAmount() * multiplier, modifier.getOperation()));
}
}
示例13: getDamage
import com.google.common.collect.Multimap; //导入方法依赖的package包/类
public float getDamage()
{
Multimap<String, AttributeModifier> modifiersMap = this.getRenderStack().getAttributeModifiers(EntityEquipmentSlot.MAINHAND);
double ret = 1;
if (modifiersMap.containsKey(SharedMonsterAttributes.ATTACK_DAMAGE.getName()))
{
for (AttributeModifier mod : modifiersMap.get(SharedMonsterAttributes.ATTACK_DAMAGE.getName()))
{
ret = mod.getOperation() == 0 ? ret + mod.getAmount() : ret * mod.getAmount();
}
}
return (float) ret;
}
示例14: checkDepths
import com.google.common.collect.Multimap; //导入方法依赖的package包/类
/**
* Check the "depth" (number of regions included at a split) of a generated
* split calculation
*/
void checkDepths(SortedSet<byte[]> splits,
Multimap<byte[], SimpleRange> regions, Integer... depths) {
assertEquals(splits.size(), depths.length);
int i = 0;
for (byte[] k : splits) {
Collection<SimpleRange> rs = regions.get(k);
int sz = rs == null ? 0 : rs.size();
assertEquals((int) depths[i], sz);
i++;
}
}
示例15: dumpOverlapProblems
import com.google.common.collect.Multimap; //导入方法依赖的package包/类
public void dumpOverlapProblems(Multimap<byte[], HbckInfo> regions) {
// we display this way because the last end key should be displayed as
// well.
for (byte[] k : regions.keySet()) {
errors.print(Bytes.toStringBinary(k) + ":");
for (HbckInfo r : regions.get(k)) {
errors.print("[ " + r.toString() + ", "
+ Bytes.toStringBinary(r.getEndKey()) + "]");
}
errors.print("----");
}
}