Example usage for com.google.common.collect Iterators getLast

List of usage examples for com.google.common.collect Iterators getLast

Introduction

In this page you can find the example usage for com.google.common.collect Iterators getLast.

Prototype

@Nullable
public static <T> T getLast(Iterator<? extends T> iterator, @Nullable T defaultValue) 

Source Link

Document

Advances iterator to the end, returning the last element or defaultValue if the iterator is empty.

Usage

From source file:com.github.fge.jsonpatch.AddOperation.java

@Override
public void applyToBuilder(ExpressionSpecBuilder builder) {
    final TokenResolver<JsonNode> node = Iterators.getLast(path.iterator(), null /*default*/);
    if (null == node || "-".equals(node.getToken().getRaw())) {
        //list_append
        throw new UnsupportedOperationException("list_append not supported yet");
    } else {//  w w  w . j a v a2 s.  c o m
        super.applyToBuilder(builder);
    }
}

From source file:org.lbogdanov.poker.web.markup.ControlGroup.java

/**
 * Returns the last child <code>FormComponent</code>.
 * //from w  w w. ja v a2 s .c  o  m
 * @return the last child of type <code>FormComponent</code>
 */
private FormComponent<?> lastFormComponent() {
    // TODO More tricky traversal?
    return (FormComponent<?>) Iterators.getLast(getBodyContainer().visitChildren(FormComponent.class), null);
}