Skip to content

Commit d1bda7e

Browse files
committed
Update README.md.
1 parent 5441fbf commit d1bda7e

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

README.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1034,7 +1034,6 @@ The `Collections` class provides a set of static utility methods for declarative
10341034
```java
10351035
public static <E> List<E> listOf(E... elements) { ... }
10361036
public static <K, V> Map<K, V> mapOf(Map.Entry<K, V>... entries) { ... }
1037-
public static <K, V> Map.Entry<K, V> entry(K key, V value) { ... }
10381037
public static <E> Set<E> setOf(E... elements) { ... }
10391038
```
10401039

@@ -1046,6 +1045,12 @@ public static <K, V> Map<K, V> immutableMapOf(Map.Entry<K, V>... entries) { ...
10461045
public static <E> Set<E> immutableSetOf(E... elements) { ... }
10471046
```
10481047

1048+
This method can be used to declare entries for either `mapOf()` or `immutableMapOf()`:
1049+
1050+
```java
1051+
public static <K, V> Map.Entry<K, V> entry(K key, V value) { ... }
1052+
```
1053+
10491054
`Collections` also includes support for declaring empty lists, maps, and sets:
10501055

10511056
```java
@@ -1063,8 +1068,8 @@ var list2 = emptyListOf(Integer.class);
10631068
var map1 = java.util.Collections.<String, Integer>emptyMap();
10641069
var map2 = emptyMapOf(String.class, Integer.class);
10651070

1066-
var set1 = java.util.Collections.<Integer>emptySet();
1067-
var set2 = emptySetOf(Integer.class);
1071+
var set1 = java.util.Collections.<String>emptySet();
1072+
var set2 = emptySetOf(String.class);
10681073
```
10691074

10701075
The `Optionals` class contains methods for working with optional (or "nullable") values:

kilo-client/src/test/java/org/httprpc/kilo/util/CollectionsTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,8 @@ public void testEmptyMapOf() {
124124

125125
@Test
126126
public void testEmptySetOf() {
127-
var set1 = java.util.Collections.<Integer>emptySet();
128-
var set2 = emptySetOf(Integer.class);
127+
var set1 = java.util.Collections.<String>emptySet();
128+
var set2 = emptySetOf(String.class);
129129

130130
assertTrue(set2.isEmpty());
131131
assertEquals(set1, set2);

0 commit comments

Comments
 (0)