io.vavr.collection.Map.map()方法的使用及代码示例

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

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

Map.map介绍

[英]Maps the Map entries to a sequence of values.

Please use #map(BiFunction) if the result has to be of type Map.
[中]将映射条目映射到一系列值。
如果结果必须是map类型,请使用#map(双功能)。

代码示例

代码示例来源:origin: vavr-io/vavr

@SuppressWarnings("unchecked")
static <K, V, M extends Map<K, V>> M replaceAll(M map, BiFunction<? super K, ? super V, ? extends V> function) {
  return (M) map.map((k, v) -> Tuple(k, function.apply(k, v)));
}

代码示例来源:origin: apache/incubator-pinot

private static Map<String, ?> subset(String prefix, Map<String, ?> config) {
 final int prefixLength = prefix.length();
 return config.filter((key, value) -> key.startsWith(prefix))
   .map((key, value) -> Tuple.of(key.substring(prefixLength), value));
}

代码示例来源:origin: apache/incubator-pinot

@Override
public java.util.Map<String, T> handleChildKeys(Map<String, ?> childKeys, String pathPrefix) {
 java.util.Map<String, T> returnedMap = new HashMap<>();
 childKeys.groupBy(tuple2 -> tuple2._1.split("\\.", 2)[0]).map((key, values) -> {
  // Drop the prefix
  Map<String, ?> valuesWithoutPrefix =
    values.map((configKey, configValue) -> Tuple.of(configKey.substring(key.length() + 1), configValue));
  T value;
  try {
   value = Deserializer.deserialize(_type, valuesWithoutPrefix, "");
  } catch (Exception e) {
   value = null;
   e.printStackTrace();
  }
  return Tuple.of(key, value);
 }).forEach(returnedMap::put);
 if (returnedMap.isEmpty()) {
  return null;
 } else {
  return returnedMap;
 }
}

代码示例来源:origin: apache/incubator-pinot

@Override
 public Map<String, ?> unhandleChildKeys(java.util.Map<String, T> value, String pathPrefix) {
  if (value == null) {
   return null;
  }

  final io.vavr.collection.HashMap<String, ?> serialized = io.vavr.collection.HashMap.ofAll(value).flatMap(
    (columnName, columnPartitionConfig) -> Serializer.serialize(columnPartitionConfig)
      .map((key, obj) -> Tuple.of(columnName + "." + key, obj)));
  return serialized;
 }
}

代码示例来源:origin: apache/incubator-pinot

@Override
public java.util.List<T> handleChildKeys(Map<String, ?> childKeys, String pathPrefix) {
 Seq<T> valueList = childKeys.groupBy(tuple2 -> tuple2._1.split("\\.", 2)[0]).flatMap(tuple2 -> {
  String key = tuple2._1;
  Map<String, ?> values = tuple2._2;
  // Drop the prefix
  Map<String, Object> valuesWithoutPrefix =
    values.map((configKey, configValue) -> Tuple.of(configKey.substring(key.length() + 1), configValue));
  valuesWithoutPrefix = valuesWithoutPrefix.put("name", key);
  T value;
  try {
   value = Deserializer.deserialize(_type, valuesWithoutPrefix, "");
   return Option.some(value);
  } catch (Exception e) {
   e.printStackTrace();
   return Option.none();
  }
 });
 return valueList.asJava();
}

代码示例来源:origin: apache/incubator-pinot

Map serializedChildMap = childKeyHandler.unhandleChildKeys(field.get(object), keyName);
if (serializedChildMap != null) {
 serializedChildMap = serializedChildMap.map((key, value) -> Tuple.of(keyName + "." + key, value));
 values = values.merge(serializedChildMap);

代码示例来源:origin: apache/incubator-pinot

public static <T> String serializeToPropertiesString(T object) {
 ConfigRenderOptions configRenderOptions =
   ConfigRenderOptions.defaults().setJson(false).setOriginComments(false).setFormatted(false);
 return serialize(object).map(
   keyValueTuple -> keyValueTuple._1 + "=" + ConfigValueFactory.fromAnyRef(keyValueTuple._2)
     .render(configRenderOptions)).sorted().mkString("\n");
}

代码示例来源:origin: io.vavr/vavr

@SuppressWarnings("unchecked")
static <K, V, M extends Map<K, V>> M replaceAll(M map, BiFunction<? super K, ? super V, ? extends V> function) {
  return (M) map.map((k, v) -> Tuple(k, function.apply(k, v)));
}

代码示例来源:origin: HalBuilder/halbuilder-core

representation
  .getNamespaces()
  .map(ns -> Links.create(CURIES, ns._2, "name", ns._1)));

相关文章