List of usage examples for com.google.common.collect ImmutableList copyOf
public static <E> ImmutableList<E> copyOf(E[] elements)
From source file:org.jclouds.etcd.domain.members.Member.java
@SerializedNames({ "id", "name", "peerURLs", "clientURLs" }) private static Member create(String id, String name, List<String> peerURLs, List<String> clientURLs) { if (clientURLs == null) clientURLs = ImmutableList.of(); return new AutoValue_Member(id, name, ImmutableList.copyOf(peerURLs), ImmutableList.copyOf(clientURLs)); }
From source file:org.gradle.internal.locking.LockOutOfDateException.java
public static LockOutOfDateException createLockOutOfDateException(String configurationName, Iterable<String> errors) { TreeFormatter treeFormatter = new TreeFormatter(); treeFormatter.node("Dependency lock state for configuration '" + configurationName + "' is out of date"); treeFormatter.startChildren();/* www. j a va 2s.c o m*/ for (String error : errors) { treeFormatter.node(error); } treeFormatter.endChildren(); return new LockOutOfDateException(treeFormatter.toString(), ImmutableList.copyOf(errors)); }
From source file:com.google.errorprone.refaster.UForLoop.java
public static UForLoop create(Iterable<? extends UStatement> initializer, @Nullable UExpression condition, Iterable<? extends UExpressionStatement> update, UStatement statement) { return new AutoValue_UForLoop(ImmutableList.copyOf(initializer), condition, ImmutableList.copyOf(update), (USimpleStatement) statement); }
From source file:org.jclouds.packet.domain.Facility.java
@SerializedNames({ "id", "name", "code", "features", "address" }) public static Facility create(final String id, String name, String code, List<String> features, Href address) { return new AutoValue_Facility(id, name, code, features == null ? ImmutableList.<String>of() : ImmutableList.copyOf(features), address); }
From source file:org.apache.james.transport.mailets.remote.delivery.Repeat.java
public static <T> List<T> repeat(T element, int times) { Preconditions.checkArgument(times >= 0, "Times argument should be strictly positive"); return ImmutableList.copyOf(Iterables.limit(Iterables.cycle(element), times)); }
From source file:com.github.steveash.jg2p.Word.java
public static Word fromGrams(Iterable<String> grams) { return new Word(ImmutableList.copyOf(grams)); }
From source file:org.ftccommunity.enigmabot.util.ClassManager.java
public static List<Class<?>> getClasses() { if (classes.isEmpty()) { throw new IllegalStateException("Class Mgr doesn't know anything yet; did you" + "call create()?"); }/*from w ww . j a v a2s.com*/ return ImmutableList.copyOf(classes); }
From source file:org.jclouds.azurecompute.arm.domain.ExtensionProfileSettings.java
@SerializedNames({ "fileUris", "commandToExecute" }) public static ExtensionProfileSettings create(final List<String> fileUris, final String commandToExecute) { return new AutoValue_ExtensionProfileSettings( fileUris == null ? ImmutableList.<String>of() : ImmutableList.copyOf(fileUris), commandToExecute); }
From source file:com.google.errorprone.refaster.UAnnotation.java
public static UAnnotation create(UTree<?> annotationType, UExpression... arguments) { return create(annotationType, ImmutableList.copyOf(arguments)); }
From source file:com.facebook.buck.rules.RetainOrderComparator.java
/** * This is meant to be used for testing when a list of objects created via EasyMock need to be * added to a SortedSet:/* www. ja v a 2s. c o m*/ * <pre> * Iterable<T> iterable; * Comparator<T> comparator = RetainOrderComparator.createComparator(iterable); * ImmutableSortedSet<T> sortedElements = ImmutableSortedSet.copyOf(comparator, iterable); * </pre> */ public static <T> Comparator<T> createComparator(Iterable<T> iterable) { final ImmutableList<T> items = ImmutableList.copyOf(iterable); return new Comparator<T>() { @Override public int compare(T a, T b) { int indexA = -1; int indexB = -1; int index = 0; for (T item : items) { // Note that == is used rather than .equals() because this is often used with a list of // objects created via EasyMock, which means it would be a pain to mock out all of the // calls to .equals(). Fortunately, most lists used during are short, so this is not // prohibitively expensive even though it is O(N). if (a == item) { indexA = index; } if (b == item) { indexB = index; } ++index; } Preconditions.checkState(indexA >= 0, "The first element must be in the collection"); Preconditions.checkState(indexB >= 0, "The second element must be in the collection"); return indexA - indexB; } }; }