class DocumentCollectionVariableIndexer implements ProcessVariableIndexer {

    @Override
    public List<VariableInstanceLog> index(String name, Object variable) {
        DocumentCollection<? extends Document> documentCollection = (DocumentCollection<? extends Document>) variable;

        int max = documentCollection.getDocuments().size();

        return IntStream.range(0, max)
                .mapToObj(index -> toVariableLog(name, index, max, documentCollection.getDocuments().get(index)))
                .collect(Collectors.toList());
    }

}