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

x33g5p2x  于2022-01-20 转载在 其他  
字(11.2k)|赞(0)|评价(0)|浏览(212)

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

HashMap.of介绍

[英]Returns a singleton HashMap, i.e. a HashMap of one element.
[中]返回单个HashMap,即一个元素的HashMap。

代码示例

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

/**
 * Alias for {@link HashMap#of(Object, Object)}
 *
 * @param <K> The key type.
 * @param <V> The value type.
 * @param k1  The key
 * @param v1  The value
 * @return A new {@link HashMap} instance containing the given entries
 */
public static <K, V> Map<K, V> Map(K k1, V v1) {
  return HashMap.of(k1, v1);
}

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

@Override
 public io.vavr.collection.Map<String, ?> unhandleChildKeys(Map<String, Map<String, String>> value,
   String pathPrefix) {
  HashMap<String, String> retVal = HashMap.ofAll(value).flatMap((taskKey, configs) -> {
   if (!configs.isEmpty()) {
    return HashMap.ofAll(configs).map((configKey, configValue) -> Tuple.of(taskKey + "." + configKey, configValue));
   } else {
    return HashMap.of(taskKey, "");
   }
  });

  return retVal;
 }
}

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

/**
 * Alias for {@link HashMap#of(Object, Object, Object, Object)}
 *
 * @param <K> The key type.
 * @param <V> The value type.
 * @param k1  The key of the 1st pair
 * @param v1  The value of the 1st pair
 * @param k2  The key of the 2nd pair
 * @param v2  The value of the 2nd pair
 * @return A new {@link HashMap} instance containing the given entries
 */
public static <K, V> Map<K, V> Map(K k1, V v1, K k2, V v2) {
  return HashMap.of(k1, v1, k2, v2);
}

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

/**
 * Alias for {@link HashMap#of(Object, Object, Object, Object, Object, Object)}
 *
 * @param <K> The key type.
 * @param <V> The value type.
 * @param k1  The key of the 1st pair
 * @param v1  The value of the 1st pair
 * @param k2  The key of the 2nd pair
 * @param v2  The value of the 2nd pair
 * @param k3  The key of the 3rd pair
 * @param v3  The value of the 3rd pair
 * @return A new {@link HashMap} instance containing the given entries
 */
public static <K, V> Map<K, V> Map(K k1, V v1, K k2, V v2, K k3, V v3) {
  return HashMap.of(k1, v1, k2, v2, k3, v3);
}

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

/**
 * Alias for {@link HashMap#of(Object, Object, Object, Object, Object, Object, Object, Object)}
 *
 * @param <K> The key type.
 * @param <V> The value type.
 * @param k1  The key of the 1st pair
 * @param v1  The value of the 1st pair
 * @param k2  The key of the 2nd pair
 * @param v2  The value of the 2nd pair
 * @param k3  The key of the 3rd pair
 * @param v3  The value of the 3rd pair
 * @param k4  The key of the 4th pair
 * @param v4  The value of the 4th pair
 * @return A new {@link HashMap} instance containing the given entries
 */
public static <K, V> Map<K, V> Map(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4) {
  return HashMap.of(k1, v1, k2, v2, k3, v3, k4, v4);
}

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

/**
 * Alias for {@link HashMap#of(Object, Object, Object, Object, Object, Object, Object, Object, Object, Object)}
 *
 * @param <K> The key type.
 * @param <V> The value type.
 * @param k1  The key of the 1st pair
 * @param v1  The value of the 1st pair
 * @param k2  The key of the 2nd pair
 * @param v2  The value of the 2nd pair
 * @param k3  The key of the 3rd pair
 * @param v3  The value of the 3rd pair
 * @param k4  The key of the 4th pair
 * @param v4  The value of the 4th pair
 * @param k5  The key of the 5th pair
 * @param v5  The value of the 5th pair
 * @return A new {@link HashMap} instance containing the given entries
 */
public static <K, V> Map<K, V> Map(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5) {
  return HashMap.of(k1, v1, k2, v2, k3, v3, k4, v4, k5, v5);
}

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

/**
 * Alias for {@link HashMap#of(Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object)}
 *
 * @param <K> The key type.
 * @param <V> The value type.
 * @param k1  The key of the 1st pair
 * @param v1  The value of the 1st pair
 * @param k2  The key of the 2nd pair
 * @param v2  The value of the 2nd pair
 * @param k3  The key of the 3rd pair
 * @param v3  The value of the 3rd pair
 * @param k4  The key of the 4th pair
 * @param v4  The value of the 4th pair
 * @param k5  The key of the 5th pair
 * @param v5  The value of the 5th pair
 * @param k6  The key of the 6th pair
 * @param v6  The value of the 6th pair
 * @return A new {@link HashMap} instance containing the given entries
 */
public static <K, V> Map<K, V> Map(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6) {
  return HashMap.of(k1, v1, k2, v2, k3, v3, k4, v4, k5, v5, k6, v6);
}

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

/**
 * Alias for {@link HashMap#of(Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object)}
 *
 * @param <K> The key type.
 * @param <V> The value type.
 * @param k1  The key of the 1st pair
 * @param v1  The value of the 1st pair
 * @param k2  The key of the 2nd pair
 * @param v2  The value of the 2nd pair
 * @param k3  The key of the 3rd pair
 * @param v3  The value of the 3rd pair
 * @param k4  The key of the 4th pair
 * @param v4  The value of the 4th pair
 * @param k5  The key of the 5th pair
 * @param v5  The value of the 5th pair
 * @param k6  The key of the 6th pair
 * @param v6  The value of the 6th pair
 * @param k7  The key of the 7th pair
 * @param v7  The value of the 7th pair
 * @return A new {@link HashMap} instance containing the given entries
 */
public static <K, V> Map<K, V> Map(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6, K k7, V v7) {
  return HashMap.of(k1, v1, k2, v2, k3, v3, k4, v4, k5, v5, k6, v6, k7, v7);
}

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

/**
 * Creates a HashMap of the given list of key-value pairs.
 *
 * @param k1  a key for the map
 * @param v1  the value for k1
 * @param k2  a key for the map
 * @param v2  the value for k2
 * @param <K> The key type
 * @param <V> The value type
 * @return A new Map containing the given entries
 */
public static <K, V> HashMap<K, V> of(K k1, V v1, K k2, V v2) {
  return of(k1, v1).put(k2, v2);
}

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

/**
 * Creates a HashMap of the given list of key-value pairs.
 *
 * @param k1  a key for the map
 * @param v1  the value for k1
 * @param k2  a key for the map
 * @param v2  the value for k2
 * @param k3  a key for the map
 * @param v3  the value for k3
 * @param <K> The key type
 * @param <V> The value type
 * @return A new Map containing the given entries
 */
public static <K, V> HashMap<K, V> of(K k1, V v1, K k2, V v2, K k3, V v3) {
  return of(k1, v1, k2, v2).put(k3, v3);
}

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

/**
 * Creates a HashMap of the given list of key-value pairs.
 *
 * @param <K> The key type
 * @param <V> The value type
 * @param k1  a key for the map
 * @param v1  the value for k1
 * @param k2  a key for the map
 * @param v2  the value for k2
 * @param k3  a key for the map
 * @param v3  the value for k3
 * @param k4  a key for the map
 * @param v4  the value for k4
 * @return A new Map containing the given entries
 */
public static <K, V> HashMap<K, V> of(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4) {
  return of(k1, v1, k2, v2, k3, v3).put(k4, v4);
}

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

/**
 * Creates a HashMap of the given list of key-value pairs.
 *
 * @param k1  a key for the map
 * @param v1  the value for k1
 * @param k2  a key for the map
 * @param v2  the value for k2
 * @param k3  a key for the map
 * @param v3  the value for k3
 * @param k4  a key for the map
 * @param v4  the value for k4
 * @param k5  a key for the map
 * @param v5  the value for k5
 * @param <K> The key type
 * @param <V> The value type
 * @return A new Map containing the given entries
 */
public static <K, V> HashMap<K, V> of(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5) {
  return of(k1, v1, k2, v2, k3, v3, k4, v4).put(k5, v5);
}

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

/**
 * Creates a HashMap of the given list of key-value pairs.
 *
 * @param k1  a key for the map
 * @param v1  the value for k1
 * @param k2  a key for the map
 * @param v2  the value for k2
 * @param k3  a key for the map
 * @param v3  the value for k3
 * @param k4  a key for the map
 * @param v4  the value for k4
 * @param k5  a key for the map
 * @param v5  the value for k5
 * @param k6  a key for the map
 * @param v6  the value for k6
 * @param <K> The key type
 * @param <V> The value type
 * @return A new Map containing the given entries
 */
public static <K, V> HashMap<K, V> of(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6) {
  return of(k1, v1, k2, v2, k3, v3, k4, v4, k5, v5).put(k6, v6);
}

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

/**
 * Returns a singleton {@code LinkedHashMap}, i.e. a {@code LinkedHashMap} of one element.
 *
 * @param entry A map entry.
 * @param <K>   The key type
 * @param <V>   The value type
 * @return A new Map containing the given entry
 */
@SuppressWarnings("unchecked")
public static <K, V> LinkedHashMap<K, V> of(Tuple2<? extends K, ? extends V> entry) {
  final HashMap<K, V> map = HashMap.of(entry);
  final Queue<Tuple2<K, V>> list = Queue.of((Tuple2<K, V>) entry);
  return wrap(list, map);
}

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

/**
 * Returns a singleton {@code LinkedHashMap}, i.e. a {@code LinkedHashMap} of one element.
 *
 * @param key   A singleton map key.
 * @param value A singleton map value.
 * @param <K>   The key type
 * @param <V>   The value type
 * @return A new Map containing the given entry
 */
public static <K, V> LinkedHashMap<K, V> of(K key, V value) {
  final HashMap<K, V> map = HashMap.of(key, value);
  final Queue<Tuple2<K, V>> list = Queue.of(Tuple.of(key, value));
  return wrap(list, map);
}

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

/**
 * Creates a LinkedHashMap of the given list of key-value pairs.
 *
 * @param k1  a key for the map
 * @param v1  the value for k1
 * @param k2  a key for the map
 * @param v2  the value for k2
 * @param <K> The key type
 * @param <V> The value type
 * @return A new Map containing the given entries
 */
public static <K, V> LinkedHashMap<K, V> of(K k1, V v1, K k2, V v2) {
  final HashMap<K, V> map = HashMap.of(k1, v1, k2, v2);
  final Queue<Tuple2<K, V>> list = Queue.of(Tuple.of(k1, v1), Tuple.of(k2, v2));
  return wrapNonUnique(list, map);
}

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

/**
 * Creates a LinkedHashMap of the given list of key-value pairs.
 *
 * @param k1  a key for the map
 * @param v1  the value for k1
 * @param k2  a key for the map
 * @param v2  the value for k2
 * @param k3  a key for the map
 * @param v3  the value for k3
 * @param <K> The key type
 * @param <V> The value type
 * @return A new Map containing the given entries
 */
public static <K, V> LinkedHashMap<K, V> of(K k1, V v1, K k2, V v2, K k3, V v3) {
  final HashMap<K, V> map = HashMap.of(k1, v1, k2, v2, k3, v3);
  final Queue<Tuple2<K, V>> list = Queue.of(Tuple.of(k1, v1), Tuple.of(k2, v2), Tuple.of(k3, v3));
  return wrapNonUnique(list, map);
}

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

/**
 * Creates a LinkedHashMap of the given list of key-value pairs.
 *
 * @param k1  a key for the map
 * @param v1  the value for k1
 * @param k2  a key for the map
 * @param v2  the value for k2
 * @param k3  a key for the map
 * @param v3  the value for k3
 * @param k4  a key for the map
 * @param v4  the value for k4
 * @param <K> The key type
 * @param <V> The value type
 * @return A new Map containing the given entries
 */
public static <K, V> LinkedHashMap<K, V> of(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4) {
  final HashMap<K, V> map = HashMap.of(k1, v1, k2, v2, k3, v3, k4, v4);
  final Queue<Tuple2<K, V>> list = Queue.of(Tuple.of(k1, v1), Tuple.of(k2, v2), Tuple.of(k3, v3), Tuple.of(k4, v4));
  return wrapNonUnique(list, map);
}

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

/**
 * Creates a LinkedHashMap of the given list of key-value pairs.
 *
 * @param k1  a key for the map
 * @param v1  the value for k1
 * @param k2  a key for the map
 * @param v2  the value for k2
 * @param k3  a key for the map
 * @param v3  the value for k3
 * @param k4  a key for the map
 * @param v4  the value for k4
 * @param k5  a key for the map
 * @param v5  the value for k5
 * @param <K> The key type
 * @param <V> The value type
 * @return A new Map containing the given entries
 */
public static <K, V> LinkedHashMap<K, V> of(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5) {
  final HashMap<K, V> map = HashMap.of(k1, v1, k2, v2, k3, v3, k4, v4, k5, v5);
  final Queue<Tuple2<K, V>> list = Queue.of(Tuple.of(k1, v1), Tuple.of(k2, v2), Tuple.of(k3, v3), Tuple.of(k4, v4), Tuple.of(k5, v5));
  return wrapNonUnique(list, map);
}

代码示例来源:origin: resilience4j/resilience4j

@Test
public void testExportsCircuitBreakerStates() {
  // Given
  final CollectorRegistry registry = new CollectorRegistry();
  final Bulkhead bulkhead = Bulkhead.ofDefaults("foo");
  BulkheadExports.ofIterable("boo_bulkhead", singletonList(bulkhead)).register(registry);
  final Supplier<Map<String, Double>> values = () -> HashSet
      .of("available_concurrent_calls")
      .map(param ->
          Tuple.of(param, registry.getSampleValue(
              "boo_bulkhead",
              new String[]{"name", "param"},
              new String[]{"foo", param})))
      .toMap(t -> t);
  // When
  final Map<String, Double> initialValues = values.get();
  // Then
  assertThat(initialValues).isEqualTo(HashMap.of("available_concurrent_calls", 25.0));
}

相关文章