How to add a field to a list of foreign key in an object using Java 8

Viewed 31
for(TCI tci : child) {
    blueprintsList.add(tci.getBlueprint().getName());
}

I want to skip this iteration and add the names of the blueprint to my blueprints List using Java 8 feature.

I tried to add a field to list as follows:

List<Integer> idList = child.stream()
    .map(TCI::getId)
    .collect(Collectors.toList());

When I have huge data, iteration is taking time.

0 Answers
Related