cast iterable to list java code example
Example 1: java Iterable to list
@Test
public void whenConvertIterableToListUsingJava8_thenSuccess() {
List<String> result = new ArrayList<String>();
iterable.forEach(result::add);
assertThat(result, contains("john", "tom", "jane"));
}
Example 2: java lambda list of objects cast
collection.stream()
.filter(obj -> obj instanceof ScheduleIntervalContainer)
.map(obj -> (ScheduleIntervalContainer) obj)