org.eclipse.collections.api.map.MutableMap.putAll()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(11.4k)|赞(0)|评价(0)|浏览(117)

本文整理了Java中org.eclipse.collections.api.map.MutableMap.putAll()方法的一些代码示例,展示了MutableMap.putAll()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MutableMap.putAll()方法的具体详情如下:
包路径:org.eclipse.collections.api.map.MutableMap
类名称:MutableMap
方法名:putAll

MutableMap.putAll介绍

暂无

代码示例

代码示例来源:origin: eclipse/eclipse-collections

/**
 * <p>Returns the elements as a MutableMap applying the keyFunction and valueFunction to each element.</p>
 * <p>Examples:</p>
 * {@code MutableMap<Integer, String> map1 =
 * Interval.oneTo(5).stream().collect(Collectors2.toMap(Functions.identity(), Object::toString));}<br>
 * {@code MutableMap<Integer, String> map2 =
 * Interval.oneTo(5).reduceInPlace(Collectors2.toMap(Functions.identity(), Object::toString));}
 * <p>
 * Equivalent to using @{@link RichIterable#toMap(Function, Function)}
 * </p>
 * {@code MutableMap<Integer, String> map = Interval.oneTo(5).toMap(Functions.identity(), Object::toString);}
 */
public static <T, K, V> Collector<T, ?, MutableMap<K, V>> toMap(
    Function<? super T, ? extends K> keyFunction,
    Function<? super T, ? extends V> valueFunction)
{
  return Collector.of(
      Maps.mutable::empty,
      (map, each) -> map.put(keyFunction.valueOf(each), valueFunction.valueOf(each)),
      (r1, r2) ->
      {
        r1.putAll(r2);
        return r1;
      },
      EMPTY_CHARACTERISTICS);
}

代码示例来源:origin: eclipse/eclipse-collections

/**
 * <p>Returns the elements as a MutableMap applying the keyFunction and valueFunction to each element.</p>
 * <p>Examples:</p>
 * {@code MutableMap<Integer, String> map1 =
 * Interval.oneTo(5).stream().collect(Collectors2.toMap(Functions.identity(), Object::toString));}<br>
 * {@code MutableMap<Integer, String> map2 =
 * Interval.oneTo(5).reduceInPlace(Collectors2.toMap(Functions.identity(), Object::toString));}
 * <p>
 * Equivalent to using @{@link RichIterable#toMap(Function, Function)}
 * </p>
 * {@code MutableMap<Integer, String> map = Interval.oneTo(5).toMap(Functions.identity(), Object::toString);}
 */
public static <T, K, V> Collector<T, ?, MutableMap<K, V>> toMap(
    Function<? super T, ? extends K> keyFunction,
    Function<? super T, ? extends V> valueFunction)
{
  return Collector.of(
      Maps.mutable::empty,
      (map, each) -> map.put(keyFunction.valueOf(each), valueFunction.valueOf(each)),
      (r1, r2) ->
      {
        r1.putAll(r2);
        return r1;
      },
      EMPTY_CHARACTERISTICS);
}

代码示例来源:origin: eclipse/eclipse-collections

/**
 * <p>Returns the elements as an ImmutableMap applying the keyFunction and valueFunction to each element.</p>
 * <p>Examples:</p>
 * {@code ImmutableMap<Integer, String> map1 =
 * Interval.oneTo(5).stream().collect(Collectors2.toImmutableMap(Functions.identity(), Object::toString));}<br>
 * {@code ImmutableMap<Integer, String> map2 =
 * Interval.oneTo(5).reduceInPlace(Collectors2.toImmutableMap(Functions.identity(), Object::toString));}
 * <p>
 * Equivalent to using @{@link RichIterable#toMap(Function, Function)}
 * </p>
 * {@code ImmutableMap<Integer, String> map = Interval.oneTo(5).toMap(Functions.identity(), Object::toString).toImmutable();}
 */
public static <T, K, V> Collector<T, ?, ImmutableMap<K, V>> toImmutableMap(
    Function<? super T, ? extends K> keyFunction,
    Function<? super T, ? extends V> valueFunction)
{
  return Collector.<T, MutableMap<K, V>, ImmutableMap<K, V>>of(
      Maps.mutable::empty,
      (map, each) -> map.put(keyFunction.valueOf(each), valueFunction.valueOf(each)),
      (r1, r2) ->
      {
        r1.putAll(r2);
        return r1;
      },
      MutableMap::toImmutable,
      EMPTY_CHARACTERISTICS);
}

代码示例来源:origin: eclipse/eclipse-collections

/**
 * <p>Returns the elements as an ImmutableMap applying the keyFunction and valueFunction to each element.</p>
 * <p>Examples:</p>
 * {@code ImmutableMap<Integer, String> map1 =
 * Interval.oneTo(5).stream().collect(Collectors2.toImmutableMap(Functions.identity(), Object::toString));}<br>
 * {@code ImmutableMap<Integer, String> map2 =
 * Interval.oneTo(5).reduceInPlace(Collectors2.toImmutableMap(Functions.identity(), Object::toString));}
 * <p>
 * Equivalent to using @{@link RichIterable#toMap(Function, Function)}
 * </p>
 * {@code ImmutableMap<Integer, String> map = Interval.oneTo(5).toMap(Functions.identity(), Object::toString).toImmutable();}
 */
public static <T, K, V> Collector<T, ?, ImmutableMap<K, V>> toImmutableMap(
    Function<? super T, ? extends K> keyFunction,
    Function<? super T, ? extends V> valueFunction)
{
  return Collector.<T, MutableMap<K, V>, ImmutableMap<K, V>>of(
      Maps.mutable::empty,
      (map, each) -> map.put(keyFunction.valueOf(each), valueFunction.valueOf(each)),
      (r1, r2) ->
      {
        r1.putAll(r2);
        return r1;
      },
      MutableMap::toImmutable,
      EMPTY_CHARACTERISTICS);
}

代码示例来源:origin: eclipse/eclipse-collections

@Override
  public void combineOne(SumByBigDecimalProcedure<T, V> thingToCombine)
  {
    if (this.result.isEmpty())
    {
      this.result.putAll(thingToCombine.getResult());
    }
    else
    {
      thingToCombine.getResult().forEachKeyValue((key, value) -> this.result.updateValue(key, Functions0.zeroBigDecimal(), original -> original.add(value)));
    }
  }
}

代码示例来源:origin: eclipse/eclipse-collections

@Override
  public void combineOne(SumByBigIntegerProcedure<T, V> thingToCombine)
  {
    if (this.result.isEmpty())
    {
      this.result.putAll(thingToCombine.getResult());
    }
    else
    {
      thingToCombine.getResult().forEachKeyValue((key, value) -> this.result.updateValue(key, Functions0.zeroBigInteger(), original -> original.add(value)));
    }
  }
}

代码示例来源:origin: eclipse/eclipse-collections

@Override
  public void combineOne(SumByBigIntegerProcedure<T, V> thingToCombine)
  {
    if (this.result.isEmpty())
    {
      this.result.putAll(thingToCombine.getResult());
    }
    else
    {
      thingToCombine.getResult().forEachKeyValue((key, value) -> this.result.updateValue(key, Functions0.zeroBigInteger(), original -> original.add(value)));
    }
  }
}

代码示例来源:origin: eclipse/eclipse-collections

@Override
  public void combineOne(SumByBigDecimalProcedure<T, V> thingToCombine)
  {
    if (this.result.isEmpty())
    {
      this.result.putAll(thingToCombine.getResult());
    }
    else
    {
      thingToCombine.getResult().forEachKeyValue((key, value) -> this.result.updateValue(key, Functions0.zeroBigDecimal(), original -> original.add(value)));
    }
  }
}

代码示例来源:origin: org.eclipse.collections/eclipse-collections

/**
 * <p>Returns the elements as an ImmutableMap applying the keyFunction and valueFunction to each element.</p>
 * <p>Examples:</p>
 * {@code ImmutableMap<Integer, String> map1 =
 * Interval.oneTo(5).stream().collect(Collectors2.toImmutableMap(Functions.identity(), Object::toString));}<br>
 * {@code ImmutableMap<Integer, String> map2 =
 * Interval.oneTo(5).reduceInPlace(Collectors2.toImmutableMap(Functions.identity(), Object::toString));}
 * <p>
 * Equivalent to using @{@link RichIterable#toMap(Function, Function)}
 * </p>
 * {@code ImmutableMap<Integer, String> map = Interval.oneTo(5).toMap(Functions.identity(), Object::toString).toImmutable();}
 */
public static <T, K, V> Collector<T, ?, ImmutableMap<K, V>> toImmutableMap(
    Function<? super T, ? extends K> keyFunction,
    Function<? super T, ? extends V> valueFunction)
{
  return Collector.<T, MutableMap<K, V>, ImmutableMap<K, V>>of(
      Maps.mutable::empty,
      (map, each) -> map.put(keyFunction.valueOf(each), valueFunction.valueOf(each)),
      (r1, r2) ->
      {
        r1.putAll(r2);
        return r1;
      },
      MutableMap::toImmutable,
      EMPTY_CHARACTERISTICS);
}

代码示例来源:origin: org.eclipse.collections/eclipse-collections

/**
 * <p>Returns the elements as a MutableMap applying the keyFunction and valueFunction to each element.</p>
 * <p>Examples:</p>
 * {@code MutableMap<Integer, String> map1 =
 * Interval.oneTo(5).stream().collect(Collectors2.toMap(Functions.identity(), Object::toString));}<br>
 * {@code MutableMap<Integer, String> map2 =
 * Interval.oneTo(5).reduceInPlace(Collectors2.toMap(Functions.identity(), Object::toString));}
 * <p>
 * Equivalent to using @{@link RichIterable#toMap(Function, Function)}
 * </p>
 * {@code MutableMap<Integer, String> map = Interval.oneTo(5).toMap(Functions.identity(), Object::toString);}
 */
public static <T, K, V> Collector<T, ?, MutableMap<K, V>> toMap(
    Function<? super T, ? extends K> keyFunction,
    Function<? super T, ? extends V> valueFunction)
{
  return Collector.of(
      Maps.mutable::empty,
      (map, each) -> map.put(keyFunction.valueOf(each), valueFunction.valueOf(each)),
      (r1, r2) ->
      {
        r1.putAll(r2);
        return r1;
      },
      EMPTY_CHARACTERISTICS);
}

代码示例来源:origin: org.eclipse.collections/eclipse-collections

@Override
  public void combineOne(SumByBigDecimalProcedure<T, V> thingToCombine)
  {
    if (this.result.isEmpty())
    {
      this.result.putAll(thingToCombine.getResult());
    }
    else
    {
      thingToCombine.getResult().forEachKeyValue((key, value) -> this.result.updateValue(key, Functions0.zeroBigDecimal(), original -> original.add(value)));
    }
  }
}

代码示例来源:origin: org.eclipse.collections/eclipse-collections

@Override
  public void combineOne(SumByBigIntegerProcedure<T, V> thingToCombine)
  {
    if (this.result.isEmpty())
    {
      this.result.putAll(thingToCombine.getResult());
    }
    else
    {
      thingToCombine.getResult().forEachKeyValue((key, value) -> this.result.updateValue(key, Functions0.zeroBigInteger(), original -> original.add(value)));
    }
  }
}

代码示例来源:origin: goldmansachs/obevo

protected Main() {
  // use the hashing strategy to allow commands of any case to be handled
  MutableMap<String, Procedure<String[]>> commandMap = HashingStrategyMaps.mutable.of(HashingStrategies.fromFunction(new Function<String, String>() {
    @Override
    public String valueOf(String s) {
      return s.toLowerCase();
    }
  }));
  commandMap.putAll(getCommandMap().toMap());
  this.commandMap = commandMap.toImmutable();
}

代码示例来源:origin: goldmansachs/obevo

@Override
  public String prepare(String content, ChangeInput change, DbEnvironment env) {
    MutableMap<String, String> tokens = Maps.mutable.<String, String>empty()
        .withKeyValue("dbSchemaSuffix", env.getDbSchemaSuffix())
        .withKeyValue("dbSchemaPrefix", env.getDbSchemaPrefix());

    for (Schema schema : env.getSchemas()) {
      PhysicalSchema physicalSchema = env.getPhysicalSchema(schema.getName());
      tokens.put(schema.getName() + "_physicalName", physicalSchema.getPhysicalName());
      if (env.getPlatform() != null) {
        tokens.put(schema.getName() + "_schemaSuffixed", env.getPlatform().getSchemaPrefix(physicalSchema));
        tokens.put(schema.getName() + "_subschemaSuffixed", env.getPlatform().getSubschemaPrefix(physicalSchema));
      }
    }

    if (env.getDefaultTablespace() != null) {
      tokens.put("defaultTablespace", env.getDefaultTablespace());
    }

    tokens.putAll(env.getTokens().castToMap());  // allow clients to override these values if needed

    return new Tokenizer(tokens, env.getTokenPrefix(), env.getTokenSuffix()).tokenizeString(content);
  }
}

代码示例来源:origin: com.goldmansachs.obevo/obevo-db

@Override
  public String prepare(String content, ChangeInput change, DbEnvironment env) {
    MutableMap<String, String> tokens = Maps.mutable.<String, String>empty()
        .withKeyValue("dbSchemaSuffix", env.getDbSchemaSuffix())
        .withKeyValue("dbSchemaPrefix", env.getDbSchemaPrefix());

    for (Schema schema : env.getSchemas()) {
      PhysicalSchema physicalSchema = env.getPhysicalSchema(schema.getName());
      tokens.put(schema.getName() + "_physicalName", physicalSchema.getPhysicalName());
      if (env.getPlatform() != null) {
        tokens.put(schema.getName() + "_schemaSuffixed", env.getPlatform().getSchemaPrefix(physicalSchema));
        tokens.put(schema.getName() + "_subschemaSuffixed", env.getPlatform().getSubschemaPrefix(physicalSchema));
      }
    }

    if (env.getDefaultTablespace() != null) {
      tokens.put("defaultTablespace", env.getDefaultTablespace());
    }

    tokens.putAll(env.getTokens().castToMap());  // allow clients to override these values if needed

    return new Tokenizer(tokens, env.getTokenPrefix(), env.getTokenSuffix()).tokenizeString(content);
  }
}

相关文章

MutableMap类方法