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:gobblin.util.DecoratorUtils.java

/**
 * Finds the decorator lineage of the given object.
 *
 * <p>//from w  w w  .j  a v a2 s .  co  m
 * If object is not a {@link gobblin.util.Decorator}, this method will return a singleton list with just the object.
 * If object is a {@link gobblin.util.Decorator}, it will return a list of the underlying object followed by the
 * decorator lineage up to the input decorator object.
 * </p>
 *
 * @param obj an object.
 * @return List of the non-decorator underlying object and all decorators on top of it,
 *  starting with underlying object and ending with the input object itself (inclusive).
 */
public static List<Object> getDecoratorLineage(Object obj) {
    List<Object> lineage = Lists.newArrayList(obj);
    Object currentObject = obj;
    while (currentObject instanceof Decorator) {
        currentObject = ((Decorator) currentObject).getDecoratedObject();
        lineage.add(currentObject);
    }

    return Lists.reverse(lineage);
}

From source file:org.gradle.util.internal.LimitedDescription.java

public String toString() {
    if (content.size() == 0) {
        return "<<empty>>";
    }/*from w  w  w . ja  va 2 s  .  co m*/

    StringBuilder out = new StringBuilder();
    List reversed = Lists.reverse(content);
    for (Object item : reversed) {
        out.append(item).append("\n");
    }

    return out.toString();
}

From source file:org.eclipse.mylyn.internal.wikitext.html.core.CompositeSpanStrategy.java

@Override
public void endSpan(DocumentBuilder builder) {
    for (SpanStrategy strategy : Lists.reverse(delegates)) {
        strategy.endSpan(builder);
    }
}

From source file:com.sk89q.worldedit.history.changeset.ArrayListHistory.java

@Override
public Iterator<Change> backwardIterator() {
    return Lists.reverse(changes).iterator();
}

From source file:org.locationtech.geogig.hooks.CommandHookChain.java

public void runPreHooks() throws CannotRunGeogigOperationException {
    AbstractGeoGigOp<?> command = target;
    // run pre-hooks
    for (CommandHook hook : Lists.reverse(hooks)) {
        try {/*from ww  w  .j av  a2s  .  co  m*/
            LOGGER.debug("Running pre command hook {}", hook);
            command = hook.pre(command);
        } catch (CannotRunGeogigOperationException e) {
            throw e;
        }
    }
}

From source file:com.google.errorprone.util.ErrorProneToken.java

public List<Comment> comments() {
    // javac stores the comments in reverse declaration order because appending to linked
    // lists is expensive
    return token.comments == null ? Collections.<Comment>emptyList() : Lists.reverse(token.comments);
}

From source file:com.yahoo.ycb.Dimension.java

/**
 * @param value The dimension value to start from
 * @return A list of ancestries of the value, including itself, until root (*)
 *//*from   w ww  .  ja  va  2 s  . com*/
public List<String> getAncestries(String value) {
    final ArrayList<String> result = new ArrayList<>();
    DimensionValue dimValue = valueMap.get(value);

    while (dimValue != null) {
        result.add(dimValue.value);
        dimValue = dimValue.parent;
    }

    return Lists.reverse(result);
}

From source file:uniol.aptgui.commands.CompoundCommand.java

@Override
public void undo() {
    for (Command cmd : Lists.reverse(subCommands)) {
        cmd.undo();
    }
}

From source file:com.google.testing.compile.Breadcrumbs.java

/**
 * Returns a list of breadcrumb strings describing the {@link TreePath} given.
 */// w w  w.ja  v  a2 s  .  com
static List<String> getBreadcrumbList(TreePath path) {
    return Lists.reverse(FluentIterable.from(path).transform(new Function<Tree, String>() {
        @Override
        public String apply(Tree t) {
            return t.accept(BREADCRUMB_VISITOR, null);
        }
    }).toList());
}

From source file:com.google.currysrc.processors.BaseModifyCommentScanner.java

@Override
public final void process(Context context, CompilationUnit cu) {
    Document document = context.document();
    Reporter reporter = context.reporter();
    List<Comment> comments = cu.getCommentList();
    try {/* w  ww .  j  a  v  a2 s.  c o m*/
        for (Comment comment : Lists.reverse(comments)) {
            String commentText = document.get(comment.getStartPosition(), comment.getLength());
            String newCommentText = processComment(reporter, comment, commentText);
            if (newCommentText != null) {
                document.replace(comment.getStartPosition(), comment.getLength(), newCommentText);
            }
        }
    } catch (BadLocationException e) {
        throw new AssertionError(e);
    }
}