Example usage for com.google.common.collect ImmutableList of

List of usage examples for com.google.common.collect ImmutableList of

Introduction

In this page you can find the example usage for com.google.common.collect ImmutableList of.

Prototype

public static <E> ImmutableList<E> of(E element) 

Source Link

Usage

From source file:com.github.jcustenborder.kafka.connect.utils.config.TaskConfigs.java

/**
 * Method will create a single from the supplied settings.
 *
 * @param settings/* w  ww. jav a  2 s  .c  o m*/
 * @return
 */
public static List<Map<String, String>> single(Map<String, String> settings) {
    Preconditions.checkNotNull(settings, "settings cannot be null.");
    return ImmutableList.of(settings);
}

From source file:org.trancecode.collection.TcLists.java

public static <T> List<T> immutableList(final Iterable<T> elements, final T newElement) {
    return ImmutableList.copyOf(Iterables.concat(elements, ImmutableList.of(newElement)));
}

From source file:com.google.devtools.build.importdeps.ResolutionFailureChain.java

public static ResolutionFailureChain createMissingClass(String missingClass) {
    return new AutoValue_ResolutionFailureChain(ImmutableList.of(missingClass), /*resolutionStartClass=*/ null,
            /*parentChains=*/ ImmutableList.of());
}

From source file:com.facebook.presto.execution.buffer.PageSplitterUtil.java

public static List<Page> splitPage(Page page, long maxPageSizeInBytes) {
    checkArgument(page.getPositionCount() > 0, "page is empty");
    checkArgument(maxPageSizeInBytes > 0, "maxPageSizeInBytes must be > 0");

    if (page.getSizeInBytes() <= maxPageSizeInBytes || page.getPositionCount() == 1) {
        return ImmutableList.of(page);
    }/*w  ww.  j a  va2 s.  c  o  m*/

    ImmutableList.Builder<Page> outputPages = ImmutableList.builder();
    int positionCount = page.getPositionCount();
    int half = positionCount / 2;

    Page splitPage1 = page.getRegion(0, half);
    outputPages.addAll(splitPage(splitPage1, maxPageSizeInBytes));

    Page splitPage2 = page.getRegion(half, positionCount - half);
    outputPages.addAll(splitPage(splitPage2, maxPageSizeInBytes));

    return outputPages.build();
}

From source file:com.spectralogic.ds3autogen.java.utils.ResponseParserGeneratorTestUtil.java

public static Ds3ResponseCode getNullResponseCode() {
    return new Ds3ResponseCode(200, ImmutableList.of(new Ds3ResponseType("null", null)));
}

From source file:com.google.devtools.build.skyframe.WalkableGraphUtils.java

public static Iterable<SkyKey> getReverseDeps(WalkableGraph graph, SkyKey key) throws InterruptedException {
    return Iterables.getOnlyElement(graph.getReverseDeps(ImmutableList.of(key)).values());
}

From source file:com.wrmsr.wava.util.collect.MoreOptionals.java

public static <T> List<T> optionalToList(Optional<T> o) {
    if (o.isPresent()) {
        return ImmutableList.of(o.get());
    } else {/*  w ww .j  av a 2s .co m*/
        return ImmutableList.of();
    }
}

From source file:com.demonwav.mcdev.update.Channels.java

public static List<Channels> orderedList() {
    return ImmutableList.of(SCOTLIN);
}

From source file:com.opengamma.strata.function.calculation.rate.swap.SwapLegNotionalFunction.java

private LegAmounts buildNotional(SwapTrade input) {
    List<Pair<SwapLeg, CurrencyAmount>> notionals = input.getProduct().getLegs().stream()
            .map(leg -> Pair.of(leg, buildLegNotional(leg))).collect(toList());
    CurrencyAmount firstNotional = notionals.stream().filter(pair -> pair.getSecond() != NOT_FOUND)
            .map(pair -> pair.getSecond()).findFirst()
            .orElseThrow(() -> new IllegalArgumentException("No notional found on any swap leg"));
    notionals = notionals.stream()/*w ww  . j  a v a  2s  .c o  m*/
            .map(pair -> pair.getSecond() != NOT_FOUND ? pair : Pair.of(pair.getFirst(), firstNotional))
            .collect(toList());
    ImmutableList<LegAmount> legAmounts = notionals.stream()
            .map(pair -> SwapLegAmount.of(pair.getFirst(), pair.getSecond())).collect(toImmutableList());
    return LegAmounts.of(legAmounts);
}

From source file:com.datastax.driver.core.RowUtil.java

public static Row createSingleStringRow(String value, int protocolVersion) {
    ColumnDefinitions definitions = new ColumnDefinitions(
            new Definition[] { new Definition("keyspace", "table", "column", DataType.ascii()) });
    ByteBuffer data = ByteBuffer.wrap(value.getBytes(UTF_8));
    return ArrayBackedRow.fromData(definitions, null, ProtocolVersion.fromInt(protocolVersion),
            ImmutableList.of(data));
}