/** * 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); }
@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; } }
/** * 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); }
/** * 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); }
/** * 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); }
/** * 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); }
/** * 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); }
/** * 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); }
/** * 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); }
/** * 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); }
/** * 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); }
/** * 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); }
/** * 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); }
/** * 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); }
/** * 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); }
/** * 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); }
/** * 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); }
/** * 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); }
/** * 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); }
@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)); }