Example usage for com.google.common.collect Lists reverse

List of usage examples for com.google.common.collect Lists reverse

Introduction

In this page you can find the example usage for com.google.common.collect Lists reverse.

Prototype

@CheckReturnValue
public static <T> List<T> reverse(List<T> list) 

Source Link

Document

Returns a reversed view of the specified list.

Usage

From source file:org.sonar.java.syntaxtoken.LastSyntaxTokenFinder.java

@Nullable
public static SyntaxToken lastSyntaxToken(@Nullable Tree tree) {
    if (tree == null || tree.is(Tree.Kind.INFERED_TYPE)) {
        return null;
    } else if (tree.is(Tree.Kind.TOKEN)) {
        return (SyntaxToken) tree;
    }//from   w  w  w.  ja  v a2s  .c  o m
    ArrayList<Tree> childrenAsList = Lists.newArrayList(((JavaTree) tree).children());
    for (Tree next : Lists.reverse(childrenAsList)) {
        SyntaxToken syntaxToken = lastSyntaxToken(next);
        if (syntaxToken != null) {
            return syntaxToken;
        }
    }
    return null;
}

From source file:com.nuaavee.physics.core.impl.EventProcessorImpl.java

@Override
public boolean process(final ActionEvent actionEvent) {
    for (Actionable actionableLayer : Lists.reverse(layerManager.getLayers())) {
        if (actionableLayer.handleAction(actionEvent)) {
            return true;
        }//from   w w w  . j a  v a 2 s  .  c o  m
    }
    return false;
}

From source file:io.druid.query.aggregation.AggregatorUtil.java

/**
 * returns the list of dependent postAggregators that should be calculated in order to calculate given postAgg
 *
 * @param postAggregatorList List of postAggregator, there is a restriction that the list should be in an order
 *                           such that all the dependencies of any given aggregator should occur before that aggregator.
 *                           See AggregatorUtilTest.testOutOfOrderPruneDependentPostAgg for example.
 * @param postAggName        name of the postAgg on which dependency is to be calculated
 *
 * @return the list of dependent postAggregators
 *///from   w  w  w  . ja v a  2 s  . co m
public static List<PostAggregator> pruneDependentPostAgg(List<PostAggregator> postAggregatorList,
        String postAggName) {
    LinkedList<PostAggregator> rv = Lists.newLinkedList();
    Set<String> deps = new HashSet<>();
    deps.add(postAggName);
    // Iterate backwards to find the last calculated aggregate and add dependent aggregator as we find dependencies in reverse order
    for (PostAggregator agg : Lists.reverse(postAggregatorList)) {
        if (deps.contains(agg.getName())) {
            rv.addFirst(agg); // add to the beginning of List
            deps.remove(agg.getName());
            deps.addAll(agg.getDependentFields());
        }
    }

    return rv;
}

From source file:com.netflix.spinnaker.orca.listeners.CompositeExecutionListener.java

public CompositeExecutionListener(ExecutionListener... delegates) {
    this.delegates = Arrays.asList(delegates);
    this.reversed = Lists.reverse(this.delegates);
}

From source file:org.gradle.api.internal.tasks.testing.logging.StackTraceFilter.java

public List<StackTraceElement> filter(List<StackTraceElement> stackTrace) {
    List<StackTraceElement> filtered = Lists.newArrayList();
    for (StackTraceElement element : Lists.reverse(stackTrace)) {
        if (filterSpec.isSatisfiedBy(element)) {
            filtered.add(element);//from  ww w  .  j  a va 2 s.  c o m
        }
    }
    return Lists.reverse(filtered);
}

From source file:dao.architecture.ArchitectureDao.java

/**
 * Get the list of ancestors of an application block.
 * /* w w  w  .ja va 2s. c  o  m*/
 * The first element of the list is the root node, and the last is the
 * concerned node.
 * 
 * @param id
 *            the application block id
 */
public static List<ApplicationBlock> getApplicationBlockAncestorsFromRoot(Long id) {
    ApplicationBlock leaf = getApplicationBlockById(id);
    List<ApplicationBlock> ancestors = new ArrayList<>();
    findApplicationBlockAncestors(ancestors, leaf);
    return Lists.reverse(ancestors);
}

From source file:Controllers.AtHomeDVDController.java

@RequestMapping(value = "/athomedvd")
protected ModelAndView getDVDPage(HttpServletRequest request) {

    String contextPath = request.getContextPath();
    System.out.println("Path: " + contextPath);
    request.setAttribute("contextPath", contextPath);

    List<Movie> dvds = Lists.reverse(movieService.getOldMovies());

    request.setAttribute("dvds", dvds);

    ModelAndView modelandview = new ModelAndView("athomedvd");
    return modelandview;
}

From source file:com.google.security.zynamics.zylib.types.graphs.algorithms.LengauerTarjan.java

private static <NodeType extends IGraphNode<NodeType>> int depthFirstSearch(final NodeType parent,
        final NodeType rootNode, final HashMap<NodeType, Integer> dfnums,
        final HashMap<Integer, NodeType> vertex, final HashMap<NodeType, NodeType> parents, int dfnum) {
    parents.put(rootNode, parent);//from w  w  w .  j av a2 s. c o m
    vertex.put(dfnum, rootNode);
    dfnums.put(rootNode, dfnum);
    dfnum++;

    final Stack<Pair<NodeType, NodeType>> nodeStack = new Stack<Pair<NodeType, NodeType>>();
    for (final NodeType child : Lists.reverse(rootNode.getChildren())) {
        nodeStack.push(new Pair<NodeType, NodeType>(child, rootNode));
    }
    while (!nodeStack.empty()) {
        final Pair<NodeType, NodeType> currentElement = nodeStack.pop();
        final NodeType currentNode = currentElement.first();
        final NodeType currentParent = currentElement.second();

        if (dfnums.get(currentNode) == -1) {
            dfnums.put(currentNode, dfnum);
            vertex.put(dfnum, currentNode);
            parents.put(currentNode, currentParent);

            dfnum++;

            for (final NodeType child : Lists.reverse(currentNode.getChildren())) {
                nodeStack.push(new Pair<NodeType, NodeType>(child, currentNode));
            }
        }
    }
    return dfnum - 1;
}

From source file:com.netflix.spinnaker.orca.listeners.CompositeStageListener.java

public CompositeStageListener(StageListener... delegates) {
    this.delegates = Arrays.asList(delegates);
    this.reversed = Lists.reverse(this.delegates);
}

From source file:brainleg.app.engine.visitor.CollectExceptionNamesFromTheBottomVisitor.java

public List<String> getNames() {
    return Lists.reverse(names);
}