Parcourir la source

Fixes #647 use typed empty lists

Tyler Matthews il y a 9 ans
Parent
révision
6c516fc78f

+ 1
- 1
exercises/custom-set/src/example/java/CustomSet.java Voir le fichier

@@ -11,7 +11,7 @@ public class CustomSet<T> {
11 11
     private Set<T> set;
12 12
 
13 13
     public CustomSet() {
14
-        this(Collections.EMPTY_LIST);
14
+        this(Collections.emptyList());
15 15
     }
16 16
 
17 17
     public CustomSet(Collection<T> data) {

+ 27
- 27
exercises/custom-set/src/test/java/CustomSetTest.java Voir le fichier

@@ -12,7 +12,7 @@ public class CustomSetTest {
12 12
     @Test
13 13
     public void setsWithNoElementsAreEmpty() {
14 14
         final boolean actual
15
-                = new CustomSet<>(Collections.EMPTY_LIST)
15
+                = new CustomSet<>(Collections.emptyList())
16 16
                         .isEmpty();
17 17
         assertTrue(actual);
18 18
     }
@@ -31,7 +31,7 @@ public class CustomSetTest {
31 31
     @Test
32 32
     public void nothingIsContainedInAnEmptySet() {
33 33
         final boolean actual
34
-                = new CustomSet<>(Collections.EMPTY_LIST)
34
+                = new CustomSet<>(Collections.emptyList())
35 35
                         .contains(1);
36 36
 
37 37
         assertFalse(actual);
@@ -61,9 +61,9 @@ public class CustomSetTest {
61 61
     @Test
62 62
     public void emptySetIsASubsetOfAnotherEmptySet() {
63 63
         final boolean actual
64
-                = new CustomSet<>(Collections.EMPTY_LIST)
64
+                = new CustomSet<>(Collections.emptyList())
65 65
                         .isSubset(
66
-                                new CustomSet<>(Collections.EMPTY_LIST)
66
+                                new CustomSet<>(Collections.emptyList())
67 67
                         );
68 68
 
69 69
         assertTrue(actual);
@@ -75,7 +75,7 @@ public class CustomSetTest {
75 75
         final boolean actual
76 76
                 = new CustomSet<>(Collections.singletonList(1))
77 77
                         .isSubset(
78
-                                new CustomSet<>(Collections.EMPTY_LIST)
78
+                                new CustomSet<>(Collections.emptyList())
79 79
                         );
80 80
 
81 81
         assertTrue(actual);
@@ -85,7 +85,7 @@ public class CustomSetTest {
85 85
     @Test
86 86
     public void nonEmptySetIsNotASubsetOfEmptySet() {
87 87
         final boolean actual
88
-                = new CustomSet<>(Collections.EMPTY_LIST)
88
+                = new CustomSet<>(Collections.emptyList())
89 89
                         .isSubset(
90 90
                                 new CustomSet<>(Collections.singletonList(1))
91 91
                         );
@@ -133,9 +133,9 @@ public class CustomSetTest {
133 133
     @Test
134 134
     public void theEmptySetIsDisjointWithItself() {
135 135
         final boolean actual
136
-                = new CustomSet<>(Collections.EMPTY_LIST)
136
+                = new CustomSet<>(Collections.emptyList())
137 137
                         .isDisjoint(
138
-                                new CustomSet<>(Collections.EMPTY_LIST)
138
+                                new CustomSet<>(Collections.emptyList())
139 139
                         );
140 140
 
141 141
         assertTrue(actual);
@@ -145,7 +145,7 @@ public class CustomSetTest {
145 145
     @Test
146 146
     public void emptySetIsDisjointWithNonEmptySet() {
147 147
         final boolean actual
148
-                = new CustomSet<>(Collections.EMPTY_LIST)
148
+                = new CustomSet<>(Collections.emptyList())
149 149
                         .isDisjoint(
150 150
                                 new CustomSet<>(Collections.singletonList(1))
151 151
                         );
@@ -159,7 +159,7 @@ public class CustomSetTest {
159 159
         final boolean actual
160 160
                 = new CustomSet<>(Collections.singletonList(1))
161 161
                         .isDisjoint(
162
-                                new CustomSet<>(Collections.EMPTY_LIST)
162
+                                new CustomSet<>(Collections.emptyList())
163 163
                         );
164 164
 
165 165
         assertTrue(actual);
@@ -193,9 +193,9 @@ public class CustomSetTest {
193 193
     @Test
194 194
     public void emptySetsAreEqual() {
195 195
         final boolean actual
196
-                = new CustomSet<>(Collections.EMPTY_LIST)
196
+                = new CustomSet<>(Collections.emptyList())
197 197
                         .equals(
198
-                                new CustomSet<>(Collections.EMPTY_LIST)
198
+                                new CustomSet<>(Collections.emptyList())
199 199
                         );
200 200
 
201 201
         assertTrue(actual);
@@ -205,7 +205,7 @@ public class CustomSetTest {
205 205
     @Test
206 206
     public void emptySetIsNotEqualToNonEmptySet() {
207 207
         final boolean actual
208
-                = new CustomSet<>(Collections.EMPTY_LIST)
208
+                = new CustomSet<>(Collections.emptyList())
209 209
                         .equals(
210 210
                                 new CustomSet<>(Arrays.asList(1, 2, 3))
211 211
                         );
@@ -219,7 +219,7 @@ public class CustomSetTest {
219 219
         final boolean actual
220 220
                 = new CustomSet<>(Arrays.asList(1, 2, 3))
221 221
                         .equals(
222
-                                new CustomSet<>(Collections.EMPTY_LIST)
222
+                                new CustomSet<>(Collections.emptyList())
223 223
                         );
224 224
 
225 225
         assertFalse(actual);
@@ -258,7 +258,7 @@ public class CustomSetTest {
258 258
                         Collections.unmodifiableList(Collections.singletonList(element))
259 259
                 );
260 260
         final CustomSet<Integer> actual
261
-                = new CustomSet<>(Collections.EMPTY_LIST);
261
+                = new CustomSet<>(Collections.emptyList());
262 262
 
263 263
         actual.add(element);
264 264
 
@@ -306,9 +306,9 @@ public class CustomSetTest {
306 306
     @Test
307 307
     public void intersectionOfTwoEmptySetsIsAnEmptySet() {
308 308
         final CustomSet<Integer> actual
309
-                = new CustomSet<>(Collections.EMPTY_LIST)
309
+                = new CustomSet<Integer>(Collections.emptyList())
310 310
                         .getIntersection(
311
-                                new CustomSet<>(Collections.EMPTY_LIST)
311
+                                new CustomSet<>(Collections.emptyList())
312 312
                         );
313 313
 
314 314
         assertNotNull(actual);
@@ -319,7 +319,7 @@ public class CustomSetTest {
319 319
     @Test
320 320
     public void intersectionOfAnEmptySetAndNonEmptySetIsAnEmptySet() {
321 321
         final CustomSet<Integer> actual
322
-                = new CustomSet<>(Collections.EMPTY_LIST)
322
+                = new CustomSet<Integer>(Collections.emptyList())
323 323
                         .getIntersection(
324 324
                                 new CustomSet<>(Arrays.asList(3, 2, 5))
325 325
                         );
@@ -334,7 +334,7 @@ public class CustomSetTest {
334 334
         final CustomSet<Integer> actual
335 335
                 = new CustomSet<>(Arrays.asList(1, 2, 3, 4))
336 336
                         .getIntersection(
337
-                                new CustomSet<>(Collections.EMPTY_LIST)
337
+                                new CustomSet<>(Collections.emptyList())
338 338
                         );
339 339
 
340 340
         assertNotNull(actual);
@@ -377,9 +377,9 @@ public class CustomSetTest {
377 377
     @Test
378 378
     public void differenceOfTwoEmptySetsIsAnEmptySet() {
379 379
         final CustomSet<Integer> actual
380
-                = new CustomSet<>(Collections.EMPTY_LIST)
380
+                = new CustomSet<Integer>(Collections.emptyList())
381 381
                         .getDifference(
382
-                                new CustomSet<>(Collections.EMPTY_LIST)
382
+                                new CustomSet<>(Collections.emptyList())
383 383
                         );
384 384
 
385 385
         assertNotNull(actual);
@@ -390,7 +390,7 @@ public class CustomSetTest {
390 390
     @Test
391 391
     public void differenceOfAnEmptySetAndNonEmptySetIsAnEmptySet() {
392 392
         final CustomSet<Integer> actual
393
-                = new CustomSet<>(Collections.EMPTY_LIST)
393
+                = new CustomSet<Integer>(Collections.emptyList())
394 394
                         .getDifference(
395 395
                                 new CustomSet<>(Arrays.asList(3, 2, 5))
396 396
                         );
@@ -409,7 +409,7 @@ public class CustomSetTest {
409 409
         final CustomSet<Integer> actual
410 410
                 = new CustomSet<>(Arrays.asList(1, 2, 3, 4))
411 411
                         .getDifference(
412
-                                new CustomSet<>(Collections.EMPTY_LIST)
412
+                                new CustomSet<>(Collections.emptyList())
413 413
                         );
414 414
 
415 415
         assertNotNull(actual);
@@ -439,9 +439,9 @@ public class CustomSetTest {
439 439
     @Test
440 440
     public void unionOfTwoEmptySetsIsAnEmptySet() {
441 441
         final CustomSet<Integer> actual
442
-                = new CustomSet<>(Collections.EMPTY_LIST)
442
+                = new CustomSet<Integer>(Collections.emptyList())
443 443
                         .getUnion(
444
-                                new CustomSet<>(Collections.EMPTY_LIST)
444
+                                new CustomSet<>(Collections.emptyList())
445 445
                         );
446 446
 
447 447
         assertNotNull(actual);
@@ -456,7 +456,7 @@ public class CustomSetTest {
456 456
                         Collections.unmodifiableList(Collections.singletonList(2))
457 457
                 );
458 458
         final CustomSet<Integer> actual
459
-                = new CustomSet<>(Collections.EMPTY_LIST)
459
+                = new CustomSet<Integer>(Collections.emptyList())
460 460
                         .getUnion(
461 461
                                 new CustomSet<>(Collections.singletonList(2))
462 462
                         );
@@ -476,7 +476,7 @@ public class CustomSetTest {
476 476
         final CustomSet<Integer> actual
477 477
                 = new CustomSet<>(Arrays.asList(1, 3))
478 478
                         .getUnion(
479
-                                new CustomSet<>(Collections.EMPTY_LIST)
479
+                                new CustomSet<>(Collections.emptyList())
480 480
                         );
481 481
 
482 482
         assertNotNull(actual);