Java Code Examples for com.google.common.collect.Multimap.entries()

The following are Jave code examples for showing how to use entries() of the com.google.common.collect.Multimap class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: hashsdn-controller   File: ConfigSubsystemFacade.java   Source Code and License Vote up 6 votes
private void setOnTransaction(final ConfigTransactionClient ta, final ConfigExecution execution)
        throws DocumentedException {

    for (Multimap<String, ModuleElementResolved> modulesToResolved : execution.getResolvedXmlElements(ta)
            .values()) {

        for (Map.Entry<String, ModuleElementResolved> moduleToResolved : modulesToResolved.entries()) {
            String moduleName = moduleToResolved.getKey();

            ModuleElementResolved moduleElementResolved = moduleToResolved.getValue();
            String instanceName = moduleElementResolved.getInstanceName();

            InstanceConfigElementResolved ice = moduleElementResolved.getInstanceConfigElementResolved();
            EditConfigStrategy strategy = ice.getEditStrategy();
            strategy.executeConfiguration(moduleName, instanceName, ice.getConfiguration(), ta,
                    execution.getServiceRegistryWrapper(ta));
        }
    }
}
 
Example 2
Project: guava-mock   File: MediaType.java   Source Code and License Vote up 6 votes
private static MediaType create(
    String type, String subtype, Multimap<String, String> parameters) {
  checkNotNull(type);
  checkNotNull(subtype);
  checkNotNull(parameters);
  String normalizedType = normalizeToken(type);
  String normalizedSubtype = normalizeToken(subtype);
  checkArgument(
      !WILDCARD.equals(normalizedType) || WILDCARD.equals(normalizedSubtype),
      "A wildcard type cannot be used with a non-wildcard subtype");
  ImmutableListMultimap.Builder<String, String> builder = ImmutableListMultimap.builder();
  for (Entry<String, String> entry : parameters.entries()) {
    String attribute = normalizeToken(entry.getKey());
    builder.put(attribute, normalizeParameterValue(attribute, entry.getValue()));
  }
  MediaType mediaType = new MediaType(normalizedType, normalizedSubtype, builder.build());
  // Return one of the constants if the media type is a known type.
  return MoreObjects.firstNonNull(KNOWN_TYPES.get(mediaType), mediaType);
}
 
Example 3
Project: hashsdn-controller   File: ConfigSubsystemFacade.java   Source Code and License Vote up 6 votes
private void handleMisssingInstancesOnTransaction(final ConfigTransactionClient ta, final ConfigExecution execution)
        throws DocumentedException {

    for (Multimap<String, ModuleElementDefinition> modulesToResolved : execution.getModulesDefinition(ta)
            .values()) {
        for (Map.Entry<String, ModuleElementDefinition> moduleToResolved : modulesToResolved.entries()) {
            String moduleName = moduleToResolved.getKey();

            ModuleElementDefinition moduleElementDefinition = moduleToResolved.getValue();

            EditConfigStrategy strategy = moduleElementDefinition.getEditStrategy();
            strategy.executeConfiguration(moduleName, moduleElementDefinition.getInstanceName(), null, ta,
                    execution.getServiceRegistryWrapper(ta));
        }
    }
}
 
Example 4
Project: rest-yaml-test   File: BodyAssertSelectExpression.java   Source Code and License Vote up 6 votes
public Object eval(Response response) {
	Object value = null;
	String data = response.body().asString();

	if (bodyAssert.getSelect() != null) {
		Multimap<String, List<String>> exps = parsedExpressions(bodyAssert.getSelect());

		for (Entry<String, List<String>> entry : exps.entries()) {
			if (entry.getKey().toLowerCase().startsWith(ExpressionType.jsonpath.toString().toLowerCase())) {
				value = JsonExpression.build(data, entry.getKey(), entry.getValue()).parse();
			} else if (entry.getKey().toLowerCase().startsWith(ExpressionType.regex.toString().toLowerCase())) {
				value = RegexExpression.build(data, entry.getKey(), entry.getValue()).parse();
			} else {
				throw new TestException("Expression="+entry.getKey()+" not supported in select=" + bodyAssert.getSelect());
			}
			data = JsonMapper.toJson(value);
		}

	}

	return value;
}
 
Example 5
Project: googles-monorepo-demo   File: MediaType.java   Source Code and License Vote up 6 votes
private static MediaType create(
    String type, String subtype, Multimap<String, String> parameters) {
  checkNotNull(type);
  checkNotNull(subtype);
  checkNotNull(parameters);
  String normalizedType = normalizeToken(type);
  String normalizedSubtype = normalizeToken(subtype);
  checkArgument(
      !WILDCARD.equals(normalizedType) || WILDCARD.equals(normalizedSubtype),
      "A wildcard type cannot be used with a non-wildcard subtype");
  ImmutableListMultimap.Builder<String, String> builder = ImmutableListMultimap.builder();
  for (Entry<String, String> entry : parameters.entries()) {
    String attribute = normalizeToken(entry.getKey());
    builder.put(attribute, normalizeParameterValue(attribute, entry.getValue()));
  }
  MediaType mediaType = new MediaType(normalizedType, normalizedSubtype, builder.build());
  // Return one of the constants if the media type is a known type.
  return MoreObjects.firstNonNull(KNOWN_TYPES.get(mediaType), mediaType);
}
 
Example 6
Project: r8   File: R8RunArtTestsTest.java   Source Code and License Vote up 5 votes
private static Set<String> collectTestsMatchingConditions(
    DexTool dexTool,
    CompilerUnderTest compilerUnderTest,
    DexVm dexVm,
    CompilationMode mode,
    Multimap<String, TestCondition> testConditionsMap) {
  Set<String> set = Sets.newHashSet();
  for (Map.Entry<String, TestCondition> kv : testConditionsMap.entries()) {
    if (kv.getValue().test(dexTool, compilerUnderTest, dexVm, mode)) {
      set.add(kv.getKey());
    }
  }
  return set;
}
 
Example 7
Project: DecompiledMinecraft   File: BaseAttributeMap.java   Source Code and License Vote up 5 votes
public void removeAttributeModifiers(Multimap<String, AttributeModifier> p_111148_1_)
{
    for (Entry<String, AttributeModifier> entry : p_111148_1_.entries())
    {
        IAttributeInstance iattributeinstance = this.getAttributeInstanceByName((String)entry.getKey());

        if (iattributeinstance != null)
        {
            iattributeinstance.removeModifier((AttributeModifier)entry.getValue());
        }
    }
}
 
Example 8
Project: DecompiledMinecraft   File: BaseAttributeMap.java   Source Code and License Vote up 5 votes
public void applyAttributeModifiers(Multimap<String, AttributeModifier> p_111147_1_)
{
    for (Entry<String, AttributeModifier> entry : p_111147_1_.entries())
    {
        IAttributeInstance iattributeinstance = this.getAttributeInstanceByName((String)entry.getKey());

        if (iattributeinstance != null)
        {
            iattributeinstance.removeModifier((AttributeModifier)entry.getValue());
            iattributeinstance.applyModifier((AttributeModifier)entry.getValue());
        }
    }
}
 
Example 9
Project: DecompiledMinecraft   File: BaseAttributeMap.java   Source Code and License Vote up 5 votes
public void removeAttributeModifiers(Multimap<String, AttributeModifier> p_111148_1_)
{
    for (Entry<String, AttributeModifier> entry : p_111148_1_.entries())
    {
        IAttributeInstance iattributeinstance = this.getAttributeInstanceByName((String)entry.getKey());

        if (iattributeinstance != null)
        {
            iattributeinstance.removeModifier((AttributeModifier)entry.getValue());
        }
    }
}
 
Example 10
Project: DecompiledMinecraft   File: BaseAttributeMap.java   Source Code and License Vote up 5 votes
public void applyAttributeModifiers(Multimap<String, AttributeModifier> p_111147_1_)
{
    for (Entry<String, AttributeModifier> entry : p_111147_1_.entries())
    {
        IAttributeInstance iattributeinstance = this.getAttributeInstanceByName((String)entry.getKey());

        if (iattributeinstance != null)
        {
            iattributeinstance.removeModifier((AttributeModifier)entry.getValue());
            iattributeinstance.applyModifier((AttributeModifier)entry.getValue());
        }
    }
}
 
Example 11
Project: BaseClient   File: BaseAttributeMap.java   Source Code and License Vote up 5 votes
public void applyAttributeModifiers(Multimap<String, AttributeModifier> p_111147_1_)
{
    for (Entry<String, AttributeModifier> entry : p_111147_1_.entries())
    {
        IAttributeInstance iattributeinstance = this.getAttributeInstanceByName((String)entry.getKey());

        if (iattributeinstance != null)
        {
            iattributeinstance.removeModifier((AttributeModifier)entry.getValue());
            iattributeinstance.applyModifier((AttributeModifier)entry.getValue());
        }
    }
}
 
Example 12
Project: BaseClient   File: BaseAttributeMap.java   Source Code and License Vote up 5 votes
public void removeAttributeModifiers(Multimap<String, AttributeModifier> p_111148_1_)
{
    for (Entry<String, AttributeModifier> entry : p_111148_1_.entries())
    {
        IAttributeInstance iattributeinstance = this.getAttributeInstanceByName((String)entry.getKey());

        if (iattributeinstance != null)
        {
            iattributeinstance.removeModifier((AttributeModifier)entry.getValue());
        }
    }
}
 
Example 13
Project: BaseClient   File: BaseAttributeMap.java   Source Code and License Vote up 5 votes
public void applyAttributeModifiers(Multimap<String, AttributeModifier> p_111147_1_)
{
    for (Entry<String, AttributeModifier> entry : p_111147_1_.entries())
    {
        IAttributeInstance iattributeinstance = this.getAttributeInstanceByName((String)entry.getKey());

        if (iattributeinstance != null)
        {
            iattributeinstance.removeModifier((AttributeModifier)entry.getValue());
            iattributeinstance.applyModifier((AttributeModifier)entry.getValue());
        }
    }
}
 
Example 14
Project: GuancialeDB   File: ReversibleMultiMap.java   Source Code and License Vote up 5 votes
@Override
public boolean putAll(Multimap<? extends K, ? extends V> multimap) {
    for (Entry<? extends K, ? extends V> e : multimap.entries()) {
        value2key.put(e.getValue(), e.getKey());
    }
    return key2Value.putAll(multimap);
}
 
Example 15
Project: MCBot   File: CommandCustomPing.java   Source Code and License Vote up 5 votes
private void checkCustomPing(IMessage msg) {
    if (msg.getChannel().isPrivate() || msg.getAuthor().equals(MCBot.instance.getOurUser())) return;
    
    Multimap<Long, CustomPing> pings = HashMultimap.create();
    CommandCustomPing.this.getPingsForGuild(msg.getGuild()).forEach(pings::putAll);
    for (Entry<Long, CustomPing> e : pings.entries()) {
        if (e.getKey() == msg.getAuthor().getLongID()) {
            continue;
        }
        IUser owner = msg.getGuild().getUserByID(e.getKey());
        if (owner == null || !msg.getChannel().getModifiedPermissions(owner).contains(Permissions.READ_MESSAGES)) {
            continue;
        }
        Matcher matcher = e.getValue().getPattern().matcher(msg.getContent());
        if (matcher.find()) {
            final IPrivateChannel channel = owner.getOrCreatePMChannel();
            RequestBuffer.request(() -> {
                EmbedObject embed = new EmbedBuilder()
                        .withAuthorIcon(msg.getAuthor().getAvatarURL())
                        .withAuthorName("New ping from: " + msg.getAuthor().getDisplayName(msg.getGuild()))
                        .withTitle(e.getValue().getText())
                        .withDesc(msg.getContent())
                        .build();
                channel.sendMessage("<#" + msg.getChannel().getStringID() + ">", embed);
                return true;
            });
        }
    }
}
 
Example 16
Project: Backmemed   File: AbstractAttributeMap.java   Source Code and License Vote up 5 votes
public void removeAttributeModifiers(Multimap<String, AttributeModifier> modifiers)
{
    for (Entry<String, AttributeModifier> entry : modifiers.entries())
    {
        IAttributeInstance iattributeinstance = this.getAttributeInstanceByName((String)entry.getKey());

        if (iattributeinstance != null)
        {
            iattributeinstance.removeModifier((AttributeModifier)entry.getValue());
        }
    }
}
 
Example 17
Project: Backmemed   File: AbstractAttributeMap.java   Source Code and License Vote up 5 votes
public void applyAttributeModifiers(Multimap<String, AttributeModifier> modifiers)
{
    for (Entry<String, AttributeModifier> entry : modifiers.entries())
    {
        IAttributeInstance iattributeinstance = this.getAttributeInstanceByName((String)entry.getKey());

        if (iattributeinstance != null)
        {
            iattributeinstance.removeModifier((AttributeModifier)entry.getValue());
            iattributeinstance.applyModifier((AttributeModifier)entry.getValue());
        }
    }
}
 
Example 18
Project: CustomWorldGen   File: AbstractAttributeMap.java   Source Code and License Vote up 5 votes
public void removeAttributeModifiers(Multimap<String, AttributeModifier> modifiers)
{
    for (Entry<String, AttributeModifier> entry : modifiers.entries())
    {
        IAttributeInstance iattributeinstance = this.getAttributeInstanceByName((String)entry.getKey());

        if (iattributeinstance != null)
        {
            iattributeinstance.removeModifier((AttributeModifier)entry.getValue());
        }
    }
}
 
Example 19
Project: CustomWorldGen   File: AbstractAttributeMap.java   Source Code and License Vote up 5 votes
public void applyAttributeModifiers(Multimap<String, AttributeModifier> modifiers)
{
    for (Entry<String, AttributeModifier> entry : modifiers.entries())
    {
        IAttributeInstance iattributeinstance = this.getAttributeInstanceByName((String)entry.getKey());

        if (iattributeinstance != null)
        {
            iattributeinstance.removeModifier((AttributeModifier)entry.getValue());
            iattributeinstance.applyModifier((AttributeModifier)entry.getValue());
        }
    }
}
 
Example 20
Project: dremio-oss   File: OldScanRelBase.java   Source Code and License Vote up 4 votes
/**
 * Computes the cost honoring column pushdown and relative costs across {@link GroupScan group scans}.
 *
 * The cost model is a function of row count, column and scan factors. Row count may or may not be precise and is
 * obtained from{@link GroupScan#getScanStats(PlannerSettings)}. Column factor is relative to number of columns to
 * scan. Scan factor represents the relative cost of making the scan as compared to other scans kinds.
 *
 * An exact field contributes 1 whole points to column factor. A sub field scan contributes proportionately anywhere
 * from (0, 1], weighting subsequent sub fields less through a logarithmic model.
 */
@Override
public RelOptCost computeSelfCost(final RelOptPlanner planner, final RelMetadataQuery mq) {
  final List<SchemaPath> columns = getColumns();
  final boolean isStarQuery = ColumnUtils.isStarQuery(columns);
  final int allColumns = getTable().getRowType().getFieldCount();

  final double columnFactor;
  if (isStarQuery) {
    columnFactor = allColumns;
  } else {
    double runningFactor = 0;
    // Maintain map of root to child segments to determine what fraction of a whole field is projected.
    final Multimap<NameSegment, SchemaPath> subFields = HashMultimap.create();
    for (final SchemaPath column : columns) {
      subFields.put(column.getRootSegment(), column);
    }

    for (Map.Entry<PathSegment.NameSegment, SchemaPath> entry : subFields.entries()) {
      final PathSegment.NameSegment root = entry.getKey();
      final SchemaPath field = entry.getValue();
      final String rootPath = root.getPath();
      final boolean entireColSelected = rootPath.equalsIgnoreCase(field.getAsUnescapedPath());
      if (entireColSelected) {
        runningFactor += 1;
      } else {
        final RelDataType dataType = getRowType().getField(rootPath, false, false).getType();
        final int subFieldCount = dataType.isStruct() ? dataType.getFieldCount() : 1;
        // sandwich impact of this projection between (0, 1]
        final double impact = Math.log10(1 + (Math.min(1, subFieldCount/MAX_COLUMNS) * 9));
        runningFactor += impact;
      }
    }
    columnFactor = runningFactor;
  }

  final double estimatedCount = estimateRowCount(mq);
  // If the estimatedCount is actually 0, then make it 1, so that at least, we choose the scan that
  // has fewer columns pushed down since all the cost scales with rowCount.
  final double rowCount = Math.max(1, estimatedCount);
  final double scanFactor = getGroupScan().getScanCostFactor().getFactor();
  final double cpuCost = rowCount * columnFactor * scanFactor;
  final double ioCost = cpuCost;

  if (PrelUtil.getSettings(getCluster()).useDefaultCosting()) {
    return planner.getCostFactory().makeCost(estimatedCount, cpuCost, ioCost);
  }

  final double networkCost = ioCost;
  // Even though scan is reading from disk, in the currently generated plans all plans will
  // need to read the same amount of data, so keeping the disk io cost 0 is ok for now.
  // In the future we might consider alternative scans that go against projections or
  // different compression schemes etc that affect the amount of data read. Such alternatives
  // would affect both cpu and io cost.
  final DremioCost.Factory costFactory = (DremioCost.Factory)planner.getCostFactory();
  return costFactory.makeCost(estimatedCount, cpuCost, ioCost, networkCost);
}