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

com.example.graphql.client.schema.CreateKeyspaceMutation Maven / Gradle / Ivy

There is a newer version: 2.1.0-BETA-19
Show newest version
// 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 com.example.graphql.client.schema;

import com.apollographql.apollo.api.Input;
import com.apollographql.apollo.api.Mutation;
import com.apollographql.apollo.api.Operation;
import com.apollographql.apollo.api.OperationName;
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 com.example.graphql.client.schema.type.DataCenterInput;
import java.io.IOException;
import java.lang.Boolean;
import java.lang.Integer;
import java.lang.Object;
import java.lang.Override;
import java.lang.String;
import java.lang.SuppressWarnings;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import okio.Buffer;
import okio.BufferedSource;
import okio.ByteString;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

public final class CreateKeyspaceMutation implements Mutation, CreateKeyspaceMutation.Variables> {
  public static final String OPERATION_ID = "49c473442301a5d4075f40129ca86d5d8e90e35a62aecc06302b85652ea9777c";

  public static final String QUERY_DOCUMENT = QueryDocumentMinifier.minify(
    "mutation CreateKeyspace($name: String!, $ifNotExists: Boolean, $replicas: Int, $datacenters: [DataCenterInput]) {\n"
        + "  createKeyspace(name: $name, ifNotExists: $ifNotExists, replicas: $replicas, datacenters: $datacenters)\n"
        + "}"
  );

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

  private final CreateKeyspaceMutation.Variables variables;

  public CreateKeyspaceMutation(@NotNull String name, @NotNull Input ifNotExists,
      @NotNull Input replicas, @NotNull Input> datacenters) {
    Utils.checkNotNull(name, "name == null");
    Utils.checkNotNull(ifNotExists, "ifNotExists == null");
    Utils.checkNotNull(replicas, "replicas == null");
    Utils.checkNotNull(datacenters, "datacenters == null");
    variables = new CreateKeyspaceMutation.Variables(name, ifNotExists, replicas, datacenters);
  }

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

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

  @Override
  public Optional wrapData(CreateKeyspaceMutation.Data data) {
    return Optional.ofNullable(data);
  }

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

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

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

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

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

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

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

  @Override
  @NotNull
  public Response> 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 name;

    private Input ifNotExists = Input.absent();

    private Input replicas = Input.absent();

    private Input> datacenters = Input.absent();

    Builder() {
    }

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

    public Builder ifNotExists(@Nullable Boolean ifNotExists) {
      this.ifNotExists = Input.fromNullable(ifNotExists);
      return this;
    }

    public Builder replicas(@Nullable Integer replicas) {
      this.replicas = Input.fromNullable(replicas);
      return this;
    }

    public Builder datacenters(@Nullable List datacenters) {
      this.datacenters = Input.fromNullable(datacenters);
      return this;
    }

    public Builder ifNotExistsInput(@NotNull Input ifNotExists) {
      this.ifNotExists = Utils.checkNotNull(ifNotExists, "ifNotExists == null");
      return this;
    }

    public Builder replicasInput(@NotNull Input replicas) {
      this.replicas = Utils.checkNotNull(replicas, "replicas == null");
      return this;
    }

    public Builder datacentersInput(@NotNull Input> datacenters) {
      this.datacenters = Utils.checkNotNull(datacenters, "datacenters == null");
      return this;
    }

    public CreateKeyspaceMutation build() {
      Utils.checkNotNull(name, "name == null");
      return new CreateKeyspaceMutation(name, ifNotExists, replicas, datacenters);
    }
  }

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

    private final Input ifNotExists;

    private final Input replicas;

    private final Input> datacenters;

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

    Variables(@NotNull String name, Input ifNotExists, Input replicas,
        Input> datacenters) {
      this.name = name;
      this.ifNotExists = ifNotExists;
      this.replicas = replicas;
      this.datacenters = datacenters;
      this.valueMap.put("name", name);
      if (ifNotExists.defined) {
        this.valueMap.put("ifNotExists", ifNotExists.value);
      }
      if (replicas.defined) {
        this.valueMap.put("replicas", replicas.value);
      }
      if (datacenters.defined) {
        this.valueMap.put("datacenters", datacenters.value);
      }
    }

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

    public Input ifNotExists() {
      return ifNotExists;
    }

    public Input replicas() {
      return replicas;
    }

    public Input> datacenters() {
      return datacenters;
    }

    @Override
    public Map valueMap() {
      return Collections.unmodifiableMap(valueMap);
    }

    @Override
    public InputFieldMarshaller marshaller() {
      return new InputFieldMarshaller() {
        @Override
        public void marshal(InputFieldWriter writer) throws IOException {
          writer.writeString("name", name);
          if (ifNotExists.defined) {
            writer.writeBoolean("ifNotExists", ifNotExists.value);
          }
          if (replicas.defined) {
            writer.writeInt("replicas", replicas.value);
          }
          if (datacenters.defined) {
            writer.writeList("datacenters", datacenters.value != null ? new InputFieldWriter.ListWriter() {
              @Override
              public void write(InputFieldWriter.ListItemWriter listItemWriter) throws IOException {
                for (final DataCenterInput $item : datacenters.value) {
                  listItemWriter.writeObject($item != null ? $item.marshaller() : null);
                }
              }
            } : null);
          }
        }
      };
    }
  }

  /**
   * Data from the response after executing this GraphQL operation
   */
  public static class Data implements Operation.Data {
    static final ResponseField[] $responseFields = {
      ResponseField.forBoolean("createKeyspace", "createKeyspace", new UnmodifiableMapBuilder(4)
      .put("name", new UnmodifiableMapBuilder(2)
        .put("kind", "Variable")
        .put("variableName", "name")
        .build())
      .put("ifNotExists", new UnmodifiableMapBuilder(2)
        .put("kind", "Variable")
        .put("variableName", "ifNotExists")
        .build())
      .put("replicas", new UnmodifiableMapBuilder(2)
        .put("kind", "Variable")
        .put("variableName", "replicas")
        .build())
      .put("datacenters", new UnmodifiableMapBuilder(2)
        .put("kind", "Variable")
        .put("variableName", "datacenters")
        .build())
      .build(), true, Collections.emptyList())
    };

    final Optional createKeyspace;

    private transient volatile String $toString;

    private transient volatile int $hashCode;

    private transient volatile boolean $hashCodeMemoized;

    public Data(@Nullable Boolean createKeyspace) {
      this.createKeyspace = Optional.ofNullable(createKeyspace);
    }

    /**
     * Creates a new CQL keyspace
     */
    public Optional getCreateKeyspace() {
      return this.createKeyspace;
    }

    @SuppressWarnings({"rawtypes", "unchecked"})
    public ResponseFieldMarshaller marshaller() {
      return new ResponseFieldMarshaller() {
        @Override
        public void marshal(ResponseWriter writer) {
          writer.writeBoolean($responseFields[0], createKeyspace.isPresent() ? createKeyspace.get() : null);
        }
      };
    }

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

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

    @Override
    public int hashCode() {
      if (!$hashCodeMemoized) {
        int h = 1;
        h *= 1000003;
        h ^= createKeyspace.hashCode();
        $hashCode = h;
        $hashCodeMemoized = true;
      }
      return $hashCode;
    }

    public Builder toBuilder() {
      Builder builder = new Builder();
      builder.createKeyspace = createKeyspace.isPresent() ? createKeyspace.get() : null;
      return builder;
    }

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

    public static final class Mapper implements ResponseFieldMapper {
      @Override
      public Data map(ResponseReader reader) {
        final Boolean createKeyspace = reader.readBoolean($responseFields[0]);
        return new Data(createKeyspace);
      }
    }

    public static final class Builder {
      private @Nullable Boolean createKeyspace;

      Builder() {
      }

      public Builder createKeyspace(@Nullable Boolean createKeyspace) {
        this.createKeyspace = createKeyspace;
        return this;
      }

      public Data build() {
        return new Data(createKeyspace);
      }
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy