Example usage for com.google.common.collect ImmutableList.Builder listIterator

List of usage examples for com.google.common.collect ImmutableList.Builder listIterator

Introduction

In this page you can find the example usage for com.google.common.collect ImmutableList.Builder listIterator.

Prototype

@Override
    public UnmodifiableListIterator<E> listIterator(int index) 

Source Link

Usage

From source file:com.spotify.heroic.aggregation.Chain.java

@Override
public AggregationInstance apply(final AggregationContext context) {
    ListIterator<Aggregation> it = chain.listIterator(chain.size());

    AggregationContext current = context;
    final ImmutableSet.Builder<String> tags = ImmutableSet.builder();

    final ImmutableList.Builder<AggregationInstance> chain = ImmutableList.builder();

    while (it.hasPrevious()) {
        final AggregationInstance instance = it.previous().apply(current);
        tags.addAll(instance.requiredTags());
        current = current.withRequiredTags(tags.build());
        chain.add(instance);//from   w  ww .  j  a  va 2s  .c  o  m
    }

    return ChainInstance.fromList(Lists.reverse(chain.build()));
}