void () { Condition<String> notEmpty = o -> !o.isEmpty(); Condition<String> isThirteen = o -> "13".equals(o); JBTreeTraverser<Integer> t = numTraverser().filter(IS_ODD).regard(IS_POSITIVE); JBTreeTraverser<String> mappedA = t.map(String::valueOf, Integer::parseInt); JBTreeTraverser<String> mappedB = t.map(String::valueOf); JBTreeTraverser<Integer> mapped2A = mappedA.map(Integer::parseInt); JBTreeTraverser<Integer> mapped2B = mappedB.map(Integer::parseInt); JBTreeTraverser<Integer> mapped3A = mappedA.expand(notEmpty).regard(notEmpty).forceDisregard(isThirteen).map(o -> Integer.parseInt(o)); JBTreeTraverser<Integer> mapped3B = mappedB.expand(notEmpty).regard(notEmpty).forceDisregard(isThirteen).map(o -> Integer.parseInt(o)); JBTreeTraverser<String> mapped4A = mapped3B.map(String::valueOf).map(Integer::parseInt).map(String::valueOf); JBTreeTraverser<String> mapped4B = mapped3B.map(String::valueOf).map(Integer::parseInt).map(String::valueOf); assertFalse(mappedA.children("1").isEmpty()); assertTrue(mappedB.children("1").isEmpty()); // not supported in irreversible mapped trees assertEquals(Arrays.asList("1", "5", "7", "3", "9", "11", "13"), mappedA.toList()); assertEquals(Arrays.asList("1", "5", "7", "3", "9", "11", "13"), mappedB.toList()); assertEquals(Arrays.asList(1, 5, 7, 3, 9, 11, 13), mapped2A.toList()); assertEquals(Arrays.asList(1, 5, 7, 3, 9, 11, 13), mapped2B.toList()); assertEquals(Arrays.asList(1, 5, 7, 3, 9, 11, 13), mapped2A.reset().toList()); assertEquals(Arrays.asList(1, 5, 7, 3, 9, 11, 13), mapped2B.reset().toList()); assertEquals(t.toList(), mapped2A.toList()); assertEquals(t.toList(), mapped2B.toList()); assertEquals(Arrays.asList(1, 5, 7, 3, 9, 11), mapped3A.toList()); assertEquals(Arrays.asList(1, 5, 7, 3, 9, 11), mapped3B.toList()); assertEquals(Arrays.asList("1", "5", "7", "3", "9", "11"), mapped4A.toList()); assertEquals(Arrays.asList("1", "5", "7", "3", "9", "11"), mapped4B.toList()); }