コード例 #1
0
 @Test
 public void detect() {
   ArrayList<Integer> list = this.getIntegerList();
   Assert.assertEquals(Integer.valueOf(1), ArrayListIterate.detect(list, Predicates.equal(1)));
   //noinspection CachedNumberConstructorCall,UnnecessaryBoxing
   ArrayList<Integer> list2 =
       this.newArrayList(1, new Integer(2), 2); // test relies on having a unique instance of "2"
   Assert.assertSame(list2.get(1), ArrayListIterate.detect(list2, Predicates.equal(2)));
 }
コード例 #2
0
 @Test
 public void detectOver100() {
   ArrayList<Integer> list = new ArrayList<Integer>(Interval.oneTo(101));
   Assert.assertEquals(Integer.valueOf(1), ArrayListIterate.detect(list, Predicates.equal(1)));
 }