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:org.apache.james.backends.es.ClientProviderImpl.java

public static ClientProviderImpl forHost(String address, Integer port) {
    isValidPort(port);//from ww  w  . j  a v a 2 s. c  om
    return new ClientProviderImpl(ImmutableList.of(Host.from(address, port)));
}

From source file:com.spectralogic.ds3client.helpers.RangeHelper.java

static ImmutableCollection<Range> replaceRange(final ImmutableCollection<Range> existingRanges,
        final long numBytesTransferred, final long intendedNumBytesToTransfer) {
    Preconditions.checkState(numBytesTransferred >= 0, "numBytesTransferred must be >= 0.");
    Preconditions.checkState(intendedNumBytesToTransfer > 0, "intendedNumBytesToTransfer must be > 0.");
    Preconditions.checkState(intendedNumBytesToTransfer > numBytesTransferred,
            "intendedNumBytesToTransfer must be > numBytesTransferred");

    if (Guard.isNullOrEmpty(existingRanges)) {
        return ImmutableList
                .of(Range.byLength(numBytesTransferred, intendedNumBytesToTransfer - numBytesTransferred));
    }/*from   www  .  j  av  a  2 s .com*/

    final ImmutableList.Builder<Range> newRangesbuilder = ImmutableList.builder();

    final UnmodifiableIterator<Range> existingRangesIterator = existingRanges.iterator();

    long previousAccumulatedBytesInRanges = 0;
    long currentAccumulatedBytesInRanges = existingRanges.iterator().next().getLength();

    while (existingRangesIterator.hasNext()) {
        final Range existingRange = existingRangesIterator.next();

        if (numBytesTransferred < currentAccumulatedBytesInRanges) {
            final Range firstNewRange = Range.byPosition(
                    existingRange.getStart() - previousAccumulatedBytesInRanges + numBytesTransferred,
                    existingRange.getEnd());
            newRangesbuilder.add(firstNewRange);

            addRemainingRanges(existingRangesIterator, newRangesbuilder);
            break;
        }

        previousAccumulatedBytesInRanges += existingRange.getLength();
        currentAccumulatedBytesInRanges += existingRange.getLength();
    }

    return newRangesbuilder.build();
}

From source file:com.facebook.presto.archiveConnector.ArchivePlugin.java

@Override
public Iterable<ConnectorFactory> getConnectorFactories() {
    return ImmutableList.of(new ArchiveConnectorFactory());
}

From source file:io.prestosql.execution.buffer.PageSplitterUtil.java

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

    // for Pages with certain types of Blocks (e.g., RLE blocks) the size in bytes may remain constant
    // through the recursive calls, which causes the recursion to only terminate when page.getPositionCount() == 1
    // and create potentially a large number of Page's of size 1. So we check here that
    // if the size of the page doesn't improve from the previous call we terminate the recursion.
    if (page.getSizeInBytes() == previousPageSize || page.getSizeInBytes() <= maxPageSizeInBytes
            || page.getPositionCount() == 1) {
        return ImmutableList.of(page);
    }/*from w w  w  .j a va2  s .  co m*/

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

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

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

    return outputPages.build();
}

From source file:io.crate.operation.aggregation.impl.SumAggregation.java

public static void register(AggregationImplModule mod) {
    for (DataType t : DataTypes.NUMERIC_PRIMITIVE_TYPES) {
        mod.register(new SumAggregation(new FunctionInfo(new FunctionIdent(NAME, ImmutableList.of(t)),
                DataTypes.DOUBLE, FunctionInfo.Type.AGGREGATE)));
    }/*from   w w w .  j ava 2s.  c  om*/

}

From source file:me.yanaga.winter.data.jpa.spring.config.metadata.EnableRepositoriesMetadata.java

public static EnableRepositoriesMetadata of(AnnotationMetadata annotationMetadata) {
    List<String> packageAttributes = getPackageAttributes(annotationMetadata);
    if (packageAttributes.stream().allMatch(l -> l.isEmpty())) {
        return new EnableRepositoriesMetadata(
                ImmutableList.of(obtainPackageName(annotationMetadata.getClassName())));
    }/*  w ww.j ava2s  .  c  o  m*/
    return new EnableRepositoriesMetadata(packageAttributes);
}

From source file:com.teradata.tpcds.row.generator.RowGeneratorResult.java

public RowGeneratorResult(TableRow row) {
    this(ImmutableList.of(row), true);
}

From source file:com.yahoo.sample.integration.SimpleSource.java

@Query
public List<Person> scan() {
    Tracer trace = tracer.start("MINE", "MINE");
    try {/*w  ww  . ja  va  2 s.  c  o m*/
        return ImmutableList.of(new Person("1", "joe", 0));
    } finally {
        trace.fine("Done scanning");
        trace.end();
    }
}

From source file:com.opengamma.language.position.PortfolioIdFunction.java

private static List<MetaParameter> parameters() {
    final MetaParameter name = new MetaParameter("name", JavaTypeInfo.builder(String.class).get());
    return ImmutableList.of(name);
}

From source file:com.google.api.services.samples.dfareporting.reports.CreateReport.java

public static void runExample(Dfareporting reporting, long profileId, String reportName) throws Exception {
    // Create a date range to report on.
    DateRange dateRange = new DateRange();
    dateRange.setRelativeDateRange("YESTERDAY");

    // Create a dimension to report on.
    SortedDimension dimension = new SortedDimension();
    dimension.setName("dfa:campaign");

    // Create the criteria for the report.
    Criteria criteria = new Criteria();
    criteria.setDateRange(dateRange);//from   ww w .  j a v  a  2 s .c  om
    criteria.setDimensions(ImmutableList.of(dimension));
    criteria.setMetricNames(ImmutableList.of("dfa:clicks"));

    // Create the report.
    Report report = new Report();
    report.setCriteria(criteria);
    report.setName(reportName);
    report.setType("STANDARD");

    // Insert the report.
    Report result = reporting.reports().insert(profileId, report).execute();

    // Display the new report ID.
    System.out.printf("Standard report with ID %d was created.%n", result.getId());
}