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

com.google.cloud.pubsublite.beam.AutoOneOf_PublisherOrError Maven / Gradle / Ivy

There is a newer version: 0.23.0
Show newest version
package com.google.cloud.pubsublite.beam;

import com.google.cloud.pubsublite.MessageMetadata;
import com.google.cloud.pubsublite.internal.CheckedApiException;
import com.google.cloud.pubsublite.internal.Publisher;
import javax.annotation.Generated;

@Generated("com.google.auto.value.processor.AutoOneOfProcessor")
final class AutoOneOf_PublisherOrError {
  private AutoOneOf_PublisherOrError() {} // There are no instances of this type.

  static PublisherOrError publisher(Publisher publisher) {
    if (publisher == null) {
      throw new NullPointerException();
    }
    return new Impl_publisher(publisher);
  }

  static PublisherOrError error(CheckedApiException error) {
    if (error == null) {
      throw new NullPointerException();
    }
    return new Impl_error(error);
  }

  // Parent class that each implementation will inherit from.
  private abstract static class Parent_ extends PublisherOrError {
    @Override
    Publisher publisher() {
      throw new UnsupportedOperationException(getKind().toString());
    }
    @Override
    CheckedApiException error() {
      throw new UnsupportedOperationException(getKind().toString());
    }
  }

  // Implementation when the contained property is "publisher".
  private static final class Impl_publisher extends Parent_ {
    private final Publisher publisher;
    Impl_publisher(Publisher publisher) {
      this.publisher = publisher;
    }
    @Override
    public Publisher publisher() {
      return publisher;
    }
    @Override
    public String toString() {
      return "PublisherOrError{publisher=" + this.publisher + "}";
    }
    @Override
    public boolean equals(Object x) {
      if (x instanceof PublisherOrError) {
        PublisherOrError that = (PublisherOrError) x;
        return this.getKind() == that.getKind()
            && this.publisher.equals(that.publisher());
      } else {
        return false;
      }
    }
    @Override
    public int hashCode() {
      return publisher.hashCode();
    }
    @Override
    public PublisherOrError.Kind getKind() {
      return PublisherOrError.Kind.PUBLISHER;
    }
  }

  // Implementation when the contained property is "error".
  private static final class Impl_error extends Parent_ {
    private final CheckedApiException error;
    Impl_error(CheckedApiException error) {
      this.error = error;
    }
    @Override
    public CheckedApiException error() {
      return error;
    }
    @Override
    public String toString() {
      return "PublisherOrError{error=" + this.error + "}";
    }
    @Override
    public boolean equals(Object x) {
      if (x instanceof PublisherOrError) {
        PublisherOrError that = (PublisherOrError) x;
        return this.getKind() == that.getKind()
            && this.error.equals(that.error());
      } else {
        return false;
      }
    }
    @Override
    public int hashCode() {
      return error.hashCode();
    }
    @Override
    public PublisherOrError.Kind getKind() {
      return PublisherOrError.Kind.ERROR;
    }
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy