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

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

Introduction

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

Prototype

@GwtCompatible(serializable = true)
public static <E> ArrayList<E> newArrayList(Iterator<? extends E> elements) 

Source Link

Document

Creates a mutable ArrayList instance containing the given elements; a very thin shortcut for creating an empty list and then calling Iterators#addAll .

Usage

From source file:com.spectralogic.ds3cli.ViewType.java

public static String valuesString() {
    final ArrayList<ViewType> list = Lists.newArrayList(ViewType.values());
    return Joiner.on(", ").join(Lists.transform(list, new Function<ViewType, String>() {
        @Override//from w  w w . j a v  a 2 s  .c o m
        public String apply(final ViewType input) {
            return input.toString().toLowerCase();
        }
    }));
}

From source file:io.opencensus.implcore.tags.TagsTestUtil.java

/** Returns a collection of all tags in a {@link TagContext}. */
public static Collection<Tag> tagContextToList(TagContext tags) {
    return Lists.newArrayList(InternalUtils.getTags(tags));
}

From source file:com.mattc.argus2.util.Pairs.java

public static final <K, V> Iterator<Pair<K, V>> fromMap(final Map<K, V> map) {
    final Iterator<Map.Entry<K, V>> keys = Lists.newArrayList(map.entrySet()).iterator();
    return fromMapIterator(keys);
}

From source file:org.bitbucket.es4gwt.shared.elastic.filter.Filters.java

public static ElasticFilter and(ElasticFilter... filters) {
    return new And(Lists.newArrayList(filters));
}

From source file:org.ros.math.CollectionMath.java

public static <T extends Comparable<? super T>> T median(Collection<T> collection) {
    Preconditions.checkArgument(collection.size() > 0);
    List<T> list = Lists.newArrayList(collection);
    Collections.sort(list);/*from  w  w  w .j av  a 2  s  .  c  om*/
    return list.get(list.size() / 2);
}

From source file:org.eclipse.osee.orcs.core.internal.branch.BranchUtil.java

public static List<Branch> orderByParent(Iterable<Branch> branches) throws OseeCoreException {

    ArrayList<Branch> sorted = Lists.newArrayList(branches);
    for (int i = 0; i < sorted.size(); i++) {
        Branch current = sorted.get(i);//from  w ww.java2s.c om
        Branch parent = current.getParentBranch();
        int parentIdx = sorted.indexOf(parent);
        if (parentIdx >= 0 && parentIdx < i) {
            sorted.set(i, parent);
            sorted.set(parentIdx, current);
            i = -1; // start over
        }
    }

    return sorted;
}

From source file:github.priyatam.springrest.MockDataHelper.java

public static Driver createDriver1() {
    Address a = createAddress();/*w ww . j av  a 2 s.c om*/
    DrivingHistory dh = MockDataHelper.createDrivingHistory();

    return new Driver.Builder().withLicenseNum("Lic-123").withBirthDate(new LocalDate()).withFirstName("Sarah")
            .withLastName("Conor").withLicenseExpiryDate(new LocalDate()).withGender(Driver.Gender.FEMALE)
            .withEmail("cooldriver@junkmail123.com").withPhone("6178769876").withOccupation("hacker")
            .withFirstLicenseAtAge(23).withIsMarried(false).withAddress(a)
            .withDrivingHistory(Lists.newArrayList(dh)).build();
}

From source file:org.zalando.crypto.Decrypters.java

public static List<Decrypter> prefixedDecrypters(List<Decrypter> toFilter) {
    return Lists.newArrayList(Iterables.filter(toFilter, new PrefixedDecrypterPredicate()));
}

From source file:org.franca.core.utils.ValidationIssueConverter.java

public static String getIssuesAsString(List<Issue> issues) {
    Comparator<Issue> comparator = new Comparator<Issue>() {
        @Override//  w w  w. ja v a  2s.c om
        public int compare(Issue i1, Issue i2) {
            return i1.getLineNumber() - i2.getLineNumber();
        }
    };

    List<Issue> issuesSorted = Lists.newArrayList(issues);
    Collections.sort(issuesSorted, comparator);
    StringBuilder sb = new StringBuilder();
    for (Issue i : issuesSorted) {
        sb.append(i.getLineNumber());
        sb.append(':');
        sb.append(i.getMessage());
        sb.append(LINE_SEPARATOR);
    }

    return sb.toString();
}

From source file:org.jbb.lib.logging.health.LogbackStateStorage.java

private static void cleanUpOldStatuses() {
    ArrayList<Long> sortedStatusesTimes = Lists.newArrayList(STATUSES.descendingMap().keySet());
    Long limitTime = sortedStatusesTimes.get(Math.min(sortedStatusesTimes.size(), STORAGE_LIMIT) - 1);
    STATUSES.headMap(limitTime).clear();
}