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

xapi.io.api.DelegatingIOCallback Maven / Gradle / Ivy

Go to download

Everything needed to run a comprehensive dev environment. Just type X_ and pick a service from autocomplete; new dev modules will be added as they are built. The only dev service not included in the uber jar is xapi-dev-maven, as it includes all runtime dependencies of maven, adding ~4 seconds to build time, and 6 megabytes to the final output jar size (without xapi-dev-maven, it's ~1MB).

The newest version!
/**
 *
 */
package xapi.io.api;

import xapi.util.api.ErrorHandler;
import xapi.util.api.SuccessHandler;

/**
 * @author James X. Nelson ([email protected], @james)
 *
 */
public class DelegatingIOCallback  implements IOCallback{

  private SuccessHandler success;
  private ErrorHandler failure;
  private boolean cancel;

  public DelegatingIOCallback(final SuccessHandler success) {
    this.success = success;
  }

  public DelegatingIOCallback(final SuccessHandler success, final ErrorHandler failure) {
    this.success = success;
    this.failure = failure;
  }

  @Override
  public void onCancel() {
    success = null;
    failure = null;
    cancel = true;
  }

  @Override
  public boolean isCancelled() {
    return cancel;
  }

  @Override
  public void onError(final Throwable e) {
    if (failure != null) {
      failure.onError(e);
    }
  }

  @Override
  public void onSuccess(final V t) {
    if (success != null) {
      success.onSuccess(t);
    }
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy