1.1 --- a/samples/erasure/src-api1.0/api/Erasure.java Wed Aug 08 22:06:45 2012 +0200
1.2 +++ b/samples/erasure/src-api1.0/api/Erasure.java Wed Aug 08 22:25:24 2012 +0200
1.3 @@ -1,13 +1,13 @@
1.4 package api;
1.5
1.6 -import java.util.Set;
1.7 +import java.util.Collection;
1.8
1.9 public class Erasure {
1.10 private Erasure() {
1.11 }
1.12
1.13 // BEGIN: variance.erasure.v1
1.14 - public static boolean arePositive(Set<? extends Integer> numbers) {
1.15 + public static boolean arePositive(Collection<? extends Integer> numbers) {
1.16 for (Integer n : numbers) {
1.17 if (n <= 0) {
1.18 return false;
2.1 --- a/samples/erasure/src-api2.0/api/Erasure.java Wed Aug 08 22:06:45 2012 +0200
2.2 +++ b/samples/erasure/src-api2.0/api/Erasure.java Wed Aug 08 22:25:24 2012 +0200
2.3 @@ -1,13 +1,13 @@
2.4 package api;
2.5
2.6 -import java.util.Set;
2.7 +import java.util.Collection;
2.8
2.9 public class Erasure {
2.10 private Erasure() {
2.11 }
2.12
2.13 // BEGIN: variance.erasure.v2
2.14 - public static boolean arePositive(Set<? extends Number> numbers) {
2.15 + public static boolean arePositive(Collection<? extends Number> numbers) {
2.16 for (Number n : numbers) {
2.17 if (n.doubleValue() <= 0.0d) {
2.18 return false;
3.1 --- a/samples/erasure/src-impl/test/ErasureTest.java Wed Aug 08 22:06:45 2012 +0200
3.2 +++ b/samples/erasure/src-impl/test/ErasureTest.java Wed Aug 08 22:25:24 2012 +0200
3.3 @@ -1,18 +1,14 @@
3.4 package test;
3.5
3.6 -import api.Erasure;
3.7 -import java.util.Set;
3.8 -import java.util.TreeSet;
3.9 +import static api.Erasure.arePositive;
3.10 +import java.util.Arrays;
3.11 +import java.util.List;
3.12
3.13 public class ErasureTest {
3.14 // BEGIN: variance.erasure.test
3.15 public static void main(String[] args) {
3.16 - Set<Integer> oneToTen = new TreeSet<Integer>();
3.17 - for (int i = 1; i <= 10; i++) {
3.18 - oneToTen.add(i);
3.19 - }
3.20 -
3.21 - boolean positive = Erasure.arePositive(oneToTen);
3.22 + List<Integer> oneToTen = Arrays.asList(2, 4, 6, 8, 10);
3.23 + boolean positive = arePositive(oneToTen);
3.24 System.err.println("positive = " + positive);
3.25 assert positive : "All the numbers are positive: " + oneToTen;
3.26 }