// AUTO-GENERATED FILE. DO NOT MODIFY.
//
// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it
// found.
// It should not be modified by hand.
//
package io.sentry.apollo;

import com.apollographql.apollo.api.Operation;
import com.apollographql.apollo.api.OperationName;
import com.apollographql.apollo.api.Query;
import com.apollographql.apollo.api.Response;
import com.apollographql.apollo.api.ResponseField;
import com.apollographql.apollo.api.ScalarTypeAdapters;
import com.apollographql.apollo.api.internal.InputFieldMarshaller;
import com.apollographql.apollo.api.internal.InputFieldWriter;
import com.apollographql.apollo.api.internal.OperationRequestBodyComposer;
import com.apollographql.apollo.api.internal.QueryDocumentMinifier;
import com.apollographql.apollo.api.internal.ResponseFieldMapper;
import com.apollographql.apollo.api.internal.ResponseFieldMarshaller;
import com.apollographql.apollo.api.internal.ResponseReader;
import com.apollographql.apollo.api.internal.ResponseWriter;
import com.apollographql.apollo.api.internal.SimpleOperationResponseParser;
import com.apollographql.apollo.api.internal.UnmodifiableMapBuilder;
import com.apollographql.apollo.api.internal.Utils;
import io.sentry.apollo.type.CustomType;
import java.io.IOException;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.Map;
import okio.Buffer;
import okio.BufferedSource;
import okio.ByteString;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

@SuppressWarnings({"NullAway", "Nopen", "MissingOverride"})
public final class LaunchDetailsQuery
    implements Query<
        LaunchDetailsQuery.Data, LaunchDetailsQuery.Data, LaunchDetailsQuery.Variables> {
  public static final String OPERATION_ID =
      "022b3b829be588095d13a81e534a0e63a93d5846ce571a29999540d1cfe9870f";

  public static final String QUERY_DOCUMENT =
      QueryDocumentMinifier.minify(
          "query LaunchDetails($id:ID!) {\n"
              + "  launch(id: $id) {\n"
              + "    __typename\n"
              + "    id\n"
              + "    site\n"
              + "    mission {\n"
              + "      __typename\n"
              + "      name\n"
              + "      missionPatch(size: LARGE)\n"
              + "    }\n"
              + "  }\n"
              + "}");

  public static final OperationName OPERATION_NAME =
      new OperationName() {
        @Override
        public String name() {
          return "LaunchDetails";
        }
      };

  private final LaunchDetailsQuery.Variables variables;

  public LaunchDetailsQuery(@NotNull String id) {
    Utils.checkNotNull(id, "id == null");
    variables = new LaunchDetailsQuery.Variables(id);
  }

  @Override
  public String operationId() {
    return OPERATION_ID;
  }

  @Override
  public String queryDocument() {
    return QUERY_DOCUMENT;
  }

  @Override
  public LaunchDetailsQuery.Data wrapData(LaunchDetailsQuery.Data data) {
    return data;
  }

  @Override
  public LaunchDetailsQuery.Variables variables() {
    return variables;
  }

  @Override
  public ResponseFieldMapper<LaunchDetailsQuery.Data> responseFieldMapper() {
    return new Data.Mapper();
  }

  public static Builder builder() {
    return new Builder();
  }

  @Override
  public OperationName name() {
    return OPERATION_NAME;
  }

  @Override
  @NotNull
  public Response<LaunchDetailsQuery.Data> parse(
      @NotNull final BufferedSource source, @NotNull final ScalarTypeAdapters scalarTypeAdapters)
      throws IOException {
    return SimpleOperationResponseParser.parse(source, this, scalarTypeAdapters);
  }

  @Override
  @NotNull
  public Response<LaunchDetailsQuery.Data> parse(
      @NotNull final ByteString byteString, @NotNull final ScalarTypeAdapters scalarTypeAdapters)
      throws IOException {
    return parse(new Buffer().write(byteString), scalarTypeAdapters);
  }

  @Override
  @NotNull
  public Response<LaunchDetailsQuery.Data> parse(@NotNull final BufferedSource source)
      throws IOException {
    return parse(source, ScalarTypeAdapters.DEFAULT);
  }

  @Override
  @NotNull
  public Response<LaunchDetailsQuery.Data> parse(@NotNull final ByteString byteString)
      throws IOException {
    return parse(byteString, ScalarTypeAdapters.DEFAULT);
  }

  @Override
  @NotNull
  public ByteString composeRequestBody(@NotNull final ScalarTypeAdapters scalarTypeAdapters) {
    return OperationRequestBodyComposer.compose(this, false, true, scalarTypeAdapters);
  }

  @NotNull
  @Override
  public ByteString composeRequestBody() {
    return OperationRequestBodyComposer.compose(this, false, true, ScalarTypeAdapters.DEFAULT);
  }

  @Override
  @NotNull
  public ByteString composeRequestBody(
      final boolean autoPersistQueries,
      final boolean withQueryDocument,
      @NotNull final ScalarTypeAdapters scalarTypeAdapters) {
    return OperationRequestBodyComposer.compose(
        this, autoPersistQueries, withQueryDocument, scalarTypeAdapters);
  }

  public static final class Builder {
    private @NotNull String id;

    Builder() {}

    public Builder id(@NotNull String id) {
      this.id = id;
      return this;
    }

    public LaunchDetailsQuery build() {
      Utils.checkNotNull(id, "id == null");
      return new LaunchDetailsQuery(id);
    }
  }

  public static final class Variables extends Operation.Variables {
    private final @NotNull String id;

    private final transient Map<String, Object> valueMap = new LinkedHashMap<>();

    Variables(@NotNull String id) {
      this.id = id;
      this.valueMap.put("id", id);
    }

    public @NotNull String id() {
      return id;
    }

    @Override
    public Map<String, Object> valueMap() {
      return Collections.unmodifiableMap(valueMap);
    }

    @Override
    public InputFieldMarshaller marshaller() {
      return new InputFieldMarshaller() {
        @Override
        public void marshal(InputFieldWriter writer) throws IOException {
          writer.writeCustom("id", CustomType.ID, id);
        }
      };
    }
  }

  /** Data from the response after executing this GraphQL operation */
  public static class Data implements Operation.Data {
    static final ResponseField[] $responseFields = {
      ResponseField.forObject(
          "launch",
          "launch",
          new UnmodifiableMapBuilder<String, Object>(1)
              .put(
                  "id",
                  new UnmodifiableMapBuilder<String, Object>(2)
                      .put("kind", "Variable")
                      .put("variableName", "id")
                      .build())
              .build(),
          true,
          Collections.<ResponseField.Condition>emptyList())
    };

    final @Nullable Launch launch;

    private transient volatile String $toString;

    private transient volatile int $hashCode;

    private transient volatile boolean $hashCodeMemoized;

    public Data(@Nullable Launch launch) {
      this.launch = launch;
    }

    public @Nullable Launch launch() {
      return this.launch;
    }

    @SuppressWarnings({"rawtypes", "unchecked"})
    public ResponseFieldMarshaller marshaller() {
      return new ResponseFieldMarshaller() {
        @Override
        public void marshal(ResponseWriter writer) {
          writer.writeObject($responseFields[0], launch != null ? launch.marshaller() : null);
        }
      };
    }

    @Override
    public String toString() {
      if ($toString == null) {
        $toString = "Data{" + "launch=" + launch + "}";
      }
      return $toString;
    }

    @Override
    public boolean equals(Object o) {
      if (o == this) {
        return true;
      }
      if (o instanceof Data) {
        Data that = (Data) o;
        return ((this.launch == null) ? (that.launch == null) : this.launch.equals(that.launch));
      }
      return false;
    }

    @Override
    public int hashCode() {
      if (!$hashCodeMemoized) {
        int h = 1;
        h *= 1000003;
        h ^= (launch == null) ? 0 : launch.hashCode();
        $hashCode = h;
        $hashCodeMemoized = true;
      }
      return $hashCode;
    }

    public static final class Mapper implements ResponseFieldMapper<Data> {
      final Launch.Mapper launchFieldMapper = new Launch.Mapper();

      @Override
      public Data map(ResponseReader reader) {
        final Launch launch =
            reader.readObject(
                $responseFields[0],
                new ResponseReader.ObjectReader<Launch>() {
                  @Override
                  public Launch read(ResponseReader reader) {
                    return launchFieldMapper.map(reader);
                  }
                });
        return new Data(launch);
      }
    }
  }

  public static class Launch {
    static final ResponseField[] $responseFields = {
      ResponseField.forString(
          "__typename",
          "__typename",
          null,
          false,
          Collections.<ResponseField.Condition>emptyList()),
      ResponseField.forCustomType(
          "id", "id", null, false, CustomType.ID, Collections.<ResponseField.Condition>emptyList()),
      ResponseField.forString(
          "site", "site", null, true, Collections.<ResponseField.Condition>emptyList()),
      ResponseField.forObject(
          "mission", "mission", null, true, Collections.<ResponseField.Condition>emptyList())
    };

    final @NotNull String __typename;

    final @NotNull String id;

    final @Nullable String site;

    final @Nullable Mission mission;

    private transient volatile String $toString;

    private transient volatile int $hashCode;

    private transient volatile boolean $hashCodeMemoized;

    public Launch(
        @NotNull String __typename,
        @NotNull String id,
        @Nullable String site,
        @Nullable Mission mission) {
      this.__typename = Utils.checkNotNull(__typename, "__typename == null");
      this.id = Utils.checkNotNull(id, "id == null");
      this.site = site;
      this.mission = mission;
    }

    public @NotNull String __typename() {
      return this.__typename;
    }

    public @NotNull String id() {
      return this.id;
    }

    public @Nullable String site() {
      return this.site;
    }

    public @Nullable Mission mission() {
      return this.mission;
    }

    @SuppressWarnings({"rawtypes", "unchecked"})
    public ResponseFieldMarshaller marshaller() {
      return new ResponseFieldMarshaller() {
        @Override
        public void marshal(ResponseWriter writer) {
          writer.writeString($responseFields[0], __typename);
          writer.writeCustom((ResponseField.CustomTypeField) $responseFields[1], id);
          writer.writeString($responseFields[2], site);
          writer.writeObject($responseFields[3], mission != null ? mission.marshaller() : null);
        }
      };
    }

    @Override
    public String toString() {
      if ($toString == null) {
        $toString =
            "Launch{"
                + "__typename="
                + __typename
                + ", "
                + "id="
                + id
                + ", "
                + "site="
                + site
                + ", "
                + "mission="
                + mission
                + "}";
      }
      return $toString;
    }

    @Override
    public boolean equals(Object o) {
      if (o == this) {
        return true;
      }
      if (o instanceof Launch) {
        Launch that = (Launch) o;
        return this.__typename.equals(that.__typename)
            && this.id.equals(that.id)
            && ((this.site == null) ? (that.site == null) : this.site.equals(that.site))
            && ((this.mission == null)
                ? (that.mission == null)
                : this.mission.equals(that.mission));
      }
      return false;
    }

    @Override
    public int hashCode() {
      if (!$hashCodeMemoized) {
        int h = 1;
        h *= 1000003;
        h ^= __typename.hashCode();
        h *= 1000003;
        h ^= id.hashCode();
        h *= 1000003;
        h ^= (site == null) ? 0 : site.hashCode();
        h *= 1000003;
        h ^= (mission == null) ? 0 : mission.hashCode();
        $hashCode = h;
        $hashCodeMemoized = true;
      }
      return $hashCode;
    }

    public static final class Mapper implements ResponseFieldMapper<Launch> {
      final Mission.Mapper missionFieldMapper = new Mission.Mapper();

      @Override
      public Launch map(ResponseReader reader) {
        final String __typename = reader.readString($responseFields[0]);
        final String id = reader.readCustomType((ResponseField.CustomTypeField) $responseFields[1]);
        final String site = reader.readString($responseFields[2]);
        final Mission mission =
            reader.readObject(
                $responseFields[3],
                new ResponseReader.ObjectReader<Mission>() {
                  @Override
                  public Mission read(ResponseReader reader) {
                    return missionFieldMapper.map(reader);
                  }
                });
        return new Launch(__typename, id, site, mission);
      }
    }
  }

  public static class Mission {
    static final ResponseField[] $responseFields = {
      ResponseField.forString(
          "__typename",
          "__typename",
          null,
          false,
          Collections.<ResponseField.Condition>emptyList()),
      ResponseField.forString(
          "name", "name", null, true, Collections.<ResponseField.Condition>emptyList()),
      ResponseField.forString(
          "missionPatch",
          "missionPatch",
          new UnmodifiableMapBuilder<String, Object>(1).put("size", "LARGE").build(),
          true,
          Collections.<ResponseField.Condition>emptyList())
    };

    final @NotNull String __typename;

    final @Nullable String name;

    final @Nullable String missionPatch;

    private transient volatile String $toString;

    private transient volatile int $hashCode;

    private transient volatile boolean $hashCodeMemoized;

    public Mission(
        @NotNull String __typename, @Nullable String name, @Nullable String missionPatch) {
      this.__typename = Utils.checkNotNull(__typename, "__typename == null");
      this.name = name;
      this.missionPatch = missionPatch;
    }

    public @NotNull String __typename() {
      return this.__typename;
    }

    public @Nullable String name() {
      return this.name;
    }

    public @Nullable String missionPatch() {
      return this.missionPatch;
    }

    @SuppressWarnings({"rawtypes", "unchecked"})
    public ResponseFieldMarshaller marshaller() {
      return new ResponseFieldMarshaller() {
        @Override
        public void marshal(ResponseWriter writer) {
          writer.writeString($responseFields[0], __typename);
          writer.writeString($responseFields[1], name);
          writer.writeString($responseFields[2], missionPatch);
        }
      };
    }

    @Override
    public String toString() {
      if ($toString == null) {
        $toString =
            "Mission{"
                + "__typename="
                + __typename
                + ", "
                + "name="
                + name
                + ", "
                + "missionPatch="
                + missionPatch
                + "}";
      }
      return $toString;
    }

    @Override
    public boolean equals(Object o) {
      if (o == this) {
        return true;
      }
      if (o instanceof Mission) {
        Mission that = (Mission) o;
        return this.__typename.equals(that.__typename)
            && ((this.name == null) ? (that.name == null) : this.name.equals(that.name))
            && ((this.missionPatch == null)
                ? (that.missionPatch == null)
                : this.missionPatch.equals(that.missionPatch));
      }
      return false;
    }

    @Override
    public int hashCode() {
      if (!$hashCodeMemoized) {
        int h = 1;
        h *= 1000003;
        h ^= __typename.hashCode();
        h *= 1000003;
        h ^= (name == null) ? 0 : name.hashCode();
        h *= 1000003;
        h ^= (missionPatch == null) ? 0 : missionPatch.hashCode();
        $hashCode = h;
        $hashCodeMemoized = true;
      }
      return $hashCode;
    }

    public static final class Mapper implements ResponseFieldMapper<Mission> {
      @Override
      public Mission map(ResponseReader reader) {
        final String __typename = reader.readString($responseFields[0]);
        final String name = reader.readString($responseFields[1]);
        final String missionPatch = reader.readString($responseFields[2]);
        return new Mission(__typename, name, missionPatch);
      }
    }
  }
}
