Tabnine Logo
PageImpl.<init>
Code IndexAdd Tabnine to your IDE (free)

How to use
com.google.cloud.PageImpl
constructor

Best Java code snippets using com.google.cloud.PageImpl.<init> (Showing top 20 results out of 315)

origin: googleapis/google-cloud-java

 /** An empty {@code TableResult} to avoid making API requests to unlistable tables. */
 @InternalApi("Exposed for testing")
 public EmptyTableResult() {
  super(null, 0, new PageImpl<FieldValueList>(null, "", null));
 }
}
origin: googleapis/google-cloud-java

@Override
public Page<S> getNextPage() {
 Paginated<T> nextPage =
   runWithRetries(
     new Callable<Paginated<T>>() {
      @Override
      public Paginated<T> call() {
       return getNextPage(nextPageToken);
      }
     });
 this.nextPageToken = nextPage.getNextPageToken();
 List<S> results = new ArrayList<>();
 for (T proto : nextPage.getResults()) {
  results.add(fromProto(proto));
 }
 return new PageImpl<S>(this, nextPageToken, results);
}
origin: googleapis/google-cloud-java

 @Test
 public void testIterateAll() {
  final PageImpl<String> nextResult = new PageImpl<>(null, "c", NEXT_VALUES);
  PageImpl.NextPageFetcher<String> fetcher = new TestPageFetcher(nextResult);
  PageImpl<String> result = new PageImpl<>(fetcher, "c", VALUES);
  assertEquals(ALL_VALUES, ImmutableList.copyOf(result.iterateAll()));
 }
}
origin: googleapis/google-cloud-java

private static Page<Job> listJobs(
  final BigQueryOptions serviceOptions, final Map<BigQueryRpc.Option, ?> optionsMap) {
 Tuple<String, Iterable<com.google.api.services.bigquery.model.Job>> result =
   runWithRetries(
     new Callable<Tuple<String, Iterable<com.google.api.services.bigquery.model.Job>>>() {
      @Override
      public Tuple<String, Iterable<com.google.api.services.bigquery.model.Job>> call() {
       return serviceOptions
         .getBigQueryRpcV2()
         .listJobs(serviceOptions.getProjectId(), optionsMap);
      }
     },
     serviceOptions.getRetrySettings(),
     EXCEPTION_HANDLER,
     serviceOptions.getClock());
 String cursor = result.x();
 Iterable<Job> jobs =
   Iterables.transform(
     result.y(),
     new Function<com.google.api.services.bigquery.model.Job, Job>() {
      @Override
      public Job apply(com.google.api.services.bigquery.model.Job job) {
       return Job.fromPb(serviceOptions.getService(), job);
      }
     });
 return new PageImpl<>(new JobPageFetcher(serviceOptions, cursor, optionsMap), cursor, jobs);
}
origin: googleapis/google-cloud-java

 return new PageImpl<>(new ZonePageFetcher(serviceOptions, cursor, optionsMap), cursor, zones);
} catch (RetryHelper.RetryHelperException e) {
 throw ComputeException.translateAndThrow(e);
origin: googleapis/google-cloud-java

private static Page<Disk> listDisks(
  final ComputeOptions serviceOptions, final Map<ComputeRpc.Option, ?> optionsMap) {
 try {
  Tuple<String, Iterable<com.google.api.services.compute.model.Disk>> result =
    runWithRetries(
      new Callable<Tuple<String, Iterable<com.google.api.services.compute.model.Disk>>>() {
       @Override
       public Tuple<String, Iterable<com.google.api.services.compute.model.Disk>> call() {
        return serviceOptions.getComputeRpcV1().listDisks(optionsMap);
       }
      },
      serviceOptions.getRetrySettings(),
      EXCEPTION_HANDLER,
      serviceOptions.getClock());
  String cursor = result.x();
  Iterable<Disk> disks =
    Iterables.transform(
      result.y() == null
        ? ImmutableList.<com.google.api.services.compute.model.Disk>of()
        : result.y(),
      diskFromPb(serviceOptions));
  return new PageImpl<>(
    new AggregatedDiskPageFetcher(serviceOptions, cursor, optionsMap), cursor, disks);
 } catch (RetryHelper.RetryHelperException e) {
  throw ComputeException.translateAndThrow(e);
 }
}
origin: googleapis/google-cloud-java

private static Page<Operation> listGlobalOperations(
  final ComputeOptions serviceOptions, final Map<ComputeRpc.Option, ?> optionsMap) {
 try {
  Tuple<String, Iterable<com.google.api.services.compute.model.Operation>> result =
    runWithRetries(
      new Callable<
        Tuple<String, Iterable<com.google.api.services.compute.model.Operation>>>() {
       @Override
       public Tuple<String, Iterable<com.google.api.services.compute.model.Operation>>
         call() {
        return serviceOptions.getComputeRpcV1().listGlobalOperations(optionsMap);
       }
      },
      serviceOptions.getRetrySettings(),
      EXCEPTION_HANDLER,
      serviceOptions.getClock());
  String cursor = result.x();
  Iterable<Operation> operations =
    Iterables.transform(
      result.y() == null
        ? ImmutableList.<com.google.api.services.compute.model.Operation>of()
        : result.y(),
      operationFromPb(serviceOptions));
  return new PageImpl<>(
    new GlobalOperationPageFetcher(serviceOptions, cursor, optionsMap), cursor, operations);
 } catch (RetryHelper.RetryHelperException e) {
  throw ComputeException.translateAndThrow(e);
 }
}
origin: googleapis/google-cloud-java

@Test
public void testList() throws Exception {
 initializeExpectedBucket(4);
 PageImpl<Blob> expectedBlobPage = new PageImpl<>(null, "c", blobResults);
 expect(storage.getOptions()).andReturn(mockOptions);
 expect(storage.list(BUCKET_INFO.getName())).andReturn(expectedBlobPage);
 replay(storage);
 initializeBucket();
 Page<Blob> blobPage = bucket.list();
 Iterator<Blob> blobInfoIterator = blobPage.getValues().iterator();
 Iterator<Blob> blobIterator = blobPage.getValues().iterator();
 while (blobInfoIterator.hasNext() && blobIterator.hasNext()) {
  assertEquals(blobInfoIterator.next(), blobIterator.next());
 }
 assertFalse(blobInfoIterator.hasNext());
 assertFalse(blobIterator.hasNext());
 assertEquals(expectedBlobPage.getNextPageToken(), blobPage.getNextPageToken());
}
origin: googleapis/google-cloud-java

      : result.y(),
    subnetworkFromPb(serviceOptions));
return new PageImpl<>(
  new AggregatedSubnetworkPageFetcher(serviceOptions, cursor, optionsMap),
  cursor,
origin: googleapis/google-cloud-java

@Test
public void testList() throws Exception {
 Page<FieldValueList> page = new PageImpl<>(null, "c", ROWS);
 initializeExpectedTable(1);
 expect(bigquery.getOptions()).andReturn(mockOptions);
 expect(bigquery.listTableData(TABLE_ID1)).andReturn(new TableResult(null, ROWS.size(), page));
 expect(bigquery.listTableData(TABLE_ID1, SCHEMA))
   .andReturn(new TableResult(SCHEMA, ROWS.size(), page));
 replay(bigquery);
 initializeTable();
 Page<FieldValueList> dataPage = table.list();
 assertThat(dataPage.getValues()).containsExactlyElementsIn(ROWS).inOrder();
 dataPage = table.list(SCHEMA);
 assertThat(dataPage.getValues()).containsExactlyElementsIn(ROWS_WITH_SCHEMA).inOrder();
}
origin: googleapis/google-cloud-java

private static Page<Address> listGlobalAddresses(
  final ComputeOptions serviceOptions, final Map<ComputeRpc.Option, ?> optionsMap) {
 try {
  Tuple<String, Iterable<com.google.api.services.compute.model.Address>> result =
    runWithRetries(
      new Callable<
        Tuple<String, Iterable<com.google.api.services.compute.model.Address>>>() {
       @Override
       public Tuple<String, Iterable<com.google.api.services.compute.model.Address>>
         call() {
        return serviceOptions.getComputeRpcV1().listGlobalAddresses(optionsMap);
       }
      },
      serviceOptions.getRetrySettings(),
      EXCEPTION_HANDLER,
      serviceOptions.getClock());
  String cursor = result.x();
  Iterable<Address> operations =
    Iterables.transform(
      result.y() == null
        ? ImmutableList.<com.google.api.services.compute.model.Address>of()
        : result.y(),
      addressFromPb(serviceOptions));
  return new PageImpl<>(
    new GlobalAddressPageFetcher(serviceOptions, cursor, optionsMap), cursor, operations);
 } catch (RetryHelper.RetryHelperException e) {
  throw ComputeException.translateAndThrow(e);
 }
}
origin: googleapis/google-cloud-java

private static Page<Instance> listInstances(
  final ComputeOptions serviceOptions, final Map<ComputeRpc.Option, ?> optionsMap) {
 try {
  Tuple<String, Iterable<com.google.api.services.compute.model.Instance>> result =
    runWithRetries(
      new Callable<
        Tuple<String, Iterable<com.google.api.services.compute.model.Instance>>>() {
       @Override
       public Tuple<String, Iterable<com.google.api.services.compute.model.Instance>>
         call() {
        return serviceOptions.getComputeRpcV1().listInstances(optionsMap);
       }
      },
      serviceOptions.getRetrySettings(),
      EXCEPTION_HANDLER,
      serviceOptions.getClock());
  String cursor = result.x();
  Iterable<Instance> instances =
    Iterables.transform(
      result.y() == null
        ? ImmutableList.<com.google.api.services.compute.model.Instance>of()
        : result.y(),
      instanceFromPb(serviceOptions));
  return new PageImpl<>(
    new AggregatedInstancePageFetcher(serviceOptions, cursor, optionsMap), cursor, instances);
 } catch (RetryHelper.RetryHelperException e) {
  throw ComputeException.translateAndThrow(e);
 }
}
origin: googleapis/google-cloud-java

@Test
public void testPage() {
 final PageImpl<String> nextResult = new PageImpl<>(null, "c", NEXT_VALUES);
 PageImpl.NextPageFetcher<String> fetcher = new TestPageFetcher(nextResult);
 PageImpl<String> result = new PageImpl<>(fetcher, "c", VALUES);
 assertEquals(nextResult, result.getNextPage());
 assertEquals("c", result.getNextPageToken());
 assertEquals(VALUES, result.getValues());
}
origin: googleapis/google-cloud-java

private static Page<Disk> listDisks(
  final String zone,
  final ComputeOptions serviceOptions,
  final Map<ComputeRpc.Option, ?> optionsMap) {
 try {
  Tuple<String, Iterable<com.google.api.services.compute.model.Disk>> result =
    runWithRetries(
      new Callable<Tuple<String, Iterable<com.google.api.services.compute.model.Disk>>>() {
       @Override
       public Tuple<String, Iterable<com.google.api.services.compute.model.Disk>> call() {
        return serviceOptions.getComputeRpcV1().listDisks(zone, optionsMap);
       }
      },
      serviceOptions.getRetrySettings(),
      EXCEPTION_HANDLER,
      serviceOptions.getClock());
  String cursor = result.x();
  Iterable<Disk> disks =
    Iterables.transform(
      result.y() == null
        ? ImmutableList.<com.google.api.services.compute.model.Disk>of()
        : result.y(),
      diskFromPb(serviceOptions));
  return new PageImpl<>(
    new DiskPageFetcher(zone, serviceOptions, cursor, optionsMap), cursor, disks);
 } catch (RetryHelper.RetryHelperException e) {
  throw ComputeException.translateAndThrow(e);
 }
}
origin: googleapis/google-cloud-java

@Test
public void testListWithOptions() throws Exception {
 Page<FieldValueList> page = new PageImpl<>(null, "c", ROWS);
 initializeExpectedTable(1);
 expect(bigquery.getOptions()).andReturn(mockOptions);
 expect(bigquery.listTableData(TABLE_ID1, BigQuery.TableDataListOption.pageSize(10L)))
   .andReturn(new TableResult(null, ROWS.size(), page));
 expect(bigquery.listTableData(TABLE_ID1, SCHEMA, BigQuery.TableDataListOption.pageSize(10L)))
   .andReturn(new TableResult(SCHEMA, ROWS.size(), page));
 replay(bigquery);
 initializeTable();
 Page<FieldValueList> dataPage = table.list(BigQuery.TableDataListOption.pageSize(10L));
 assertThat(dataPage.getValues()).containsExactlyElementsIn(ROWS).inOrder();
 dataPage = table.list(SCHEMA, BigQuery.TableDataListOption.pageSize(10L));
 assertThat(dataPage.getValues()).containsExactlyElementsIn(ROWS_WITH_SCHEMA).inOrder();
}
origin: googleapis/google-cloud-java

       : result.y(),
     instanceFromPb(serviceOptions));
 return new PageImpl<>(
   new InstancePageFetcher(zone, serviceOptions, cursor, optionsMap), cursor, instances);
} catch (RetryHelper.RetryHelperException e) {
origin: googleapis/google-cloud-java

      : result.y(),
    subnetworkFromPb(serviceOptions));
return new PageImpl<>(
  new SubnetworkPageFetcher(region, serviceOptions, cursor, optionsMap),
  cursor,
origin: googleapis/google-cloud-java

private static Page<Zone> listZones(
  final DnsOptions serviceOptions, final Map<DnsRpc.Option, ?> optionsMap) {
 try {
  // get a list of managed zones
  final DnsRpc rpc = serviceOptions.getDnsRpcV1();
  DnsRpc.ListResult<ManagedZone> result =
    runWithRetries(
      new Callable<DnsRpc.ListResult<ManagedZone>>() {
       @Override
       public DnsRpc.ListResult<ManagedZone> call() {
        return rpc.listZones(optionsMap);
       }
      },
      serviceOptions.getRetrySettings(),
      EXCEPTION_HANDLER,
      serviceOptions.getClock());
  String cursor = result.pageToken();
  // transform that list into zone objects
  Iterable<Zone> zones =
    result.results() == null
      ? ImmutableList.<Zone>of()
      : Iterables.transform(result.results(), zoneFromPb(serviceOptions));
  return new PageImpl<>(new ZonePageFetcher(serviceOptions, cursor, optionsMap), cursor, zones);
 } catch (RetryHelper.RetryHelperException e) {
  throw DnsException.translateAndThrow(e);
 }
}
origin: googleapis/google-cloud-java

@Test
public void testList() throws Exception {
 initializeExpectedDataset(4);
 List<Table> tableResults =
   ImmutableList.of(
     new Table(serviceMockReturnsOptions, new Table.BuilderImpl(TABLE_INFO1)),
     new Table(serviceMockReturnsOptions, new Table.BuilderImpl(TABLE_INFO2)),
     new Table(serviceMockReturnsOptions, new Table.BuilderImpl(TABLE_INFO3)));
 PageImpl<Table> expectedPage = new PageImpl<>(null, "c", tableResults);
 expect(bigquery.getOptions()).andReturn(mockOptions);
 expect(bigquery.listTables(DATASET_INFO.getDatasetId())).andReturn(expectedPage);
 replay(bigquery);
 initializeDataset();
 Page<Table> tablePage = dataset.list();
 assertArrayEquals(
   tableResults.toArray(), Iterables.toArray(tablePage.getValues(), Table.class));
 assertEquals(expectedPage.getNextPageToken(), tablePage.getNextPageToken());
}
origin: googleapis/google-cloud-java

@Test
public void testListWithOptions() throws Exception {
 initializeExpectedDataset(4);
 List<Table> tableResults =
   ImmutableList.of(
     new Table(serviceMockReturnsOptions, new Table.BuilderImpl(TABLE_INFO1)),
     new Table(serviceMockReturnsOptions, new Table.BuilderImpl(TABLE_INFO2)),
     new Table(serviceMockReturnsOptions, new Table.BuilderImpl(TABLE_INFO3)));
 PageImpl<Table> expectedPage = new PageImpl<>(null, "c", tableResults);
 expect(bigquery.getOptions()).andReturn(mockOptions);
 expect(bigquery.listTables(DATASET_INFO.getDatasetId(), BigQuery.TableListOption.pageSize(10L)))
   .andReturn(expectedPage);
 replay(bigquery);
 initializeDataset();
 Page<Table> tablePage = dataset.list(BigQuery.TableListOption.pageSize(10L));
 assertArrayEquals(
   tableResults.toArray(), Iterables.toArray(tablePage.getValues(), Table.class));
 assertEquals(expectedPage.getNextPageToken(), tablePage.getNextPageToken());
}
com.google.cloudPageImpl<init>

Javadoc

Creates a PageImpl object. In order for the object to be serializable the results parameter must be serializable.

Popular methods of PageImpl

  • nextRequestOptions
    Utility method to construct the options map for the next page request.
  • getNextPageToken
  • getNextPage
  • getValues
  • hashCode
  • iterateAll
  • nextPage

Popular in Java

  • Running tasks concurrently on multiple threads
  • putExtra (Intent)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • getContentResolver (Context)
  • Pointer (com.sun.jna)
    An abstraction for a native pointer data type. A Pointer instance represents, on the Java side, a na
  • SimpleDateFormat (java.text)
    Formats and parses dates in a locale-sensitive manner. Formatting turns a Date into a String, and pa
  • HashSet (java.util)
    HashSet is an implementation of a Set. All optional operations (adding and removing) are supported.
  • SortedMap (java.util)
    A map that has its keys ordered. The sorting is according to either the natural ordering of its keys
  • CountDownLatch (java.util.concurrent)
    A synchronization aid that allows one or more threads to wait until a set of operations being perfor
  • DateTimeFormat (org.joda.time.format)
    Factory that creates instances of DateTimeFormatter from patterns and styles. Datetime formatting i
  • Top Sublime Text plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now