nl.topicus.jdbc.shaded.com.google.longrunning.PagedResponseWrappers Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of spanner-jdbc Show documentation
Show all versions of spanner-jdbc Show documentation
JDBC Driver for Google Cloud Spanner
/*
* Copyright 2017, Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package nl.topicus.jdbc.shaded.com.google.longrunning;
import nl.topicus.jdbc.shaded.com.google.api.core.ApiFunction;
import nl.topicus.jdbc.shaded.com.google.api.core.ApiFuture;
import nl.topicus.jdbc.shaded.com.google.api.core.ApiFutures;
import nl.topicus.jdbc.shaded.com.google.api.core.BetaApi;
import nl.topicus.jdbc.shaded.com.google.api.gax.paging.AbstractFixedSizeCollection;
import nl.topicus.jdbc.shaded.com.google.api.gax.paging.AbstractPage;
import nl.topicus.jdbc.shaded.com.google.api.gax.paging.AbstractPagedListResponse;
import nl.topicus.jdbc.shaded.com.google.api.gax.rpc.PageContext;
import java.util.List;
import nl.topicus.jdbc.shaded.javax.annotation.Generated;
// AUTO-GENERATED DOCUMENTATION AND CLASS
/**
* Wrapper class to contain paged response types for page streaming methods. Each static class
* inside this wrapper class is used as the return type of one of an API method that implements the
* page streaming pattern.
*/
@Generated("by GAPIC")
@BetaApi
public class PagedResponseWrappers {
public static class ListOperationsPagedResponse
extends AbstractPagedListResponse<
ListOperationsRequest, ListOperationsResponse, Operation, ListOperationsPage,
ListOperationsFixedSizeCollection> {
public static ApiFuture createAsync(
PageContext context,
ApiFuture futureResponse) {
ApiFuture futurePage =
ListOperationsPage.createEmptyPage().createPageAsync(context, futureResponse);
return ApiFutures.transform(
futurePage,
new ApiFunction() {
@Override
public ListOperationsPagedResponse apply(ListOperationsPage input) {
return new ListOperationsPagedResponse(input);
}
});
}
private ListOperationsPagedResponse(ListOperationsPage page) {
super(page, ListOperationsFixedSizeCollection.createEmptyCollection());
}
}
public static class ListOperationsPage
extends AbstractPage<
ListOperationsRequest, ListOperationsResponse, Operation, ListOperationsPage> {
private ListOperationsPage(
PageContext context,
ListOperationsResponse response) {
super(context, response);
}
private static ListOperationsPage createEmptyPage() {
return new ListOperationsPage(null, null);
}
@Override
protected ListOperationsPage createPage(
PageContext context,
ListOperationsResponse response) {
return new ListOperationsPage(context, response);
}
@Override
public ApiFuture createPageAsync(
PageContext context,
ApiFuture futureResponse) {
return super.createPageAsync(context, futureResponse);
}
}
public static class ListOperationsFixedSizeCollection
extends AbstractFixedSizeCollection<
ListOperationsRequest, ListOperationsResponse, Operation, ListOperationsPage,
ListOperationsFixedSizeCollection> {
private ListOperationsFixedSizeCollection(List pages, int collectionSize) {
super(pages, collectionSize);
}
private static ListOperationsFixedSizeCollection createEmptyCollection() {
return new ListOperationsFixedSizeCollection(null, 0);
}
@Override
protected ListOperationsFixedSizeCollection createCollection(
List pages, int collectionSize) {
return new ListOperationsFixedSizeCollection(pages, collectionSize);
}
}
}