All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.gooddata.sdk.service.PollResult Maven / Gradle / Ivy

There is a newer version: 3.11.1+api3
Show newest version
/*
 * (C) 2023 GoodData Corporation.
 * This source code is licensed under the BSD-style license found in the
 * LICENSE.txt file in the root directory of this source tree.
 */
package com.gooddata.sdk.service;

import java.util.concurrent.TimeUnit;

import static com.gooddata.sdk.common.util.Validate.notNull;

/**
 * Represents the result retrieved by polling on the REST API.
 */
public final class PollResult implements FutureResult {

    private final AbstractService service;

    private final PollHandler handler;

    /**
     * Creates a new instance of the result to be eventually retrieved by polling on the REST API.

* For internal use by services employing polling. * * @param service this service * @param handler poll handler */ public PollResult(final AbstractService service, final PollHandler handler) { this.service = notNull(service, "service"); this.handler = notNull(handler, "handler"); } @Override public boolean isDone() { return handler.isDone() || service.pollOnce(handler); } @Override public T get() { return get(0, null); } @Override public T get(final long timeout, final TimeUnit unit) { if (handler.isDone()) { return handler.getResult(); } return service.poll(handler, timeout, unit); } /** * Get URI used for polling * * @return URI string */ @Override public String getPollingUri() { return handler.getPollingUri(); } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy