Skip to content

Commit 04d738d

Browse files
committed
ToMap is covariant in Entry position
1 parent 52c5928 commit 04d738d

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](http://keepachangelog.com/).
55

66
## [Unreleased]
7-
_No changes_
7+
### Changed
8+
- `ToMap` accepts an `Iterable` covariant in `Map.Entry`
89

910
## [3.0.0] - 2018-05-04
1011
### Changed

src/main/java/com/jnape/palatable/lambda/functions/builtin/fn2/ToMap.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@
1717
* @param <V> the value element type
1818
* @param <M> the resulting map type
1919
*/
20-
public final class ToMap<K, V, M extends Map<K, V>> implements Fn2<Supplier<M>, Iterable<Map.Entry<K, V>>, M> {
20+
public final class ToMap<K, V, M extends Map<K, V>> implements Fn2<Supplier<M>, Iterable<? extends Map.Entry<K, V>>, M> {
2121

2222
private static final ToMap INSTANCE = new ToMap<>();
2323

2424
private ToMap() {
2525
}
2626

2727
@Override
28-
public M apply(Supplier<M> mSupplier, Iterable<Map.Entry<K, V>> entries) {
28+
public M apply(Supplier<M> mSupplier, Iterable<? extends Map.Entry<K, V>> entries) {
2929
return foldLeft((m, kv) -> {
3030
m.put(kv.getKey(), kv.getValue());
3131
return m;
@@ -37,11 +37,12 @@ public static <K, V, M extends Map<K, V>> ToMap<K, V, M> toMap() {
3737
return INSTANCE;
3838
}
3939

40-
public static <K, V, M extends Map<K, V>> Fn1<Iterable<Map.Entry<K, V>>, M> toMap(Supplier<M> mSupplier) {
40+
public static <K, V, M extends Map<K, V>> Fn1<Iterable<? extends Map.Entry<K, V>>, M> toMap(Supplier<M> mSupplier) {
4141
return ToMap.<K, V, M>toMap().apply(mSupplier);
4242
}
4343

44-
public static <K, V, M extends Map<K, V>> M toMap(Supplier<M> mSupplier, Iterable<Map.Entry<K, V>> entries) {
44+
public static <K, V, M extends Map<K, V>> M toMap(Supplier<M> mSupplier,
45+
Iterable<? extends Map.Entry<K, V>> entries) {
4546
return toMap(mSupplier).apply(entries);
4647
}
4748
}

0 commit comments

Comments
 (0)