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

com.github.twitch4j.graphql.internal.FetchLastBroadcastQuery Maven / Gradle / Ivy

The 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.github.twitch4j.graphql.internal;

import com.apollographql.apollo.api.Input;
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 com.github.twitch4j.graphql.internal.type.CustomType;
import java.io.IOException;
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.Map;
import okio.Buffer;
import okio.BufferedSource;
import okio.ByteString;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

public final class FetchLastBroadcastQuery implements Query {
  public static final String OPERATION_ID = "bf791e4ef8d446ad1d8aa2546778b5b7281fdd7a4e2281a9183eb24f6af84916";

  public static final String QUERY_DOCUMENT = QueryDocumentMinifier.minify(
    "query fetchLastBroadcast($id: ID, $login: String) {\n"
        + "  user(id: $id, login: $login) {\n"
        + "    __typename\n"
        + "    id\n"
        + "    lastBroadcast {\n"
        + "      __typename\n"
        + "      id\n"
        + "      startedAt\n"
        + "      title\n"
        + "    }\n"
        + "  }\n"
        + "}"
  );

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

  private final FetchLastBroadcastQuery.Variables variables;

  public FetchLastBroadcastQuery(@NotNull Input id, @NotNull Input login) {
    Utils.checkNotNull(id, "id == null");
    Utils.checkNotNull(login, "login == null");
    variables = new FetchLastBroadcastQuery.Variables(id, login);
  }

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

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

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

  @Override
  public FetchLastBroadcastQuery.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 Input id = Input.absent();

    private Input login = Input.absent();

    Builder() {
    }

    public Builder id(@Nullable String id) {
      this.id = Input.fromNullable(id);
      return this;
    }

    public Builder login(@Nullable String login) {
      this.login = Input.fromNullable(login);
      return this;
    }

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

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

    public FetchLastBroadcastQuery build() {
      return new FetchLastBroadcastQuery(id, login);
    }
  }

  public static final class Variables extends Operation.Variables {
    private final Input id;

    private final Input login;

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

    Variables(Input id, Input login) {
      this.id = id;
      this.login = login;
      if (id.defined) {
        this.valueMap.put("id", id.value);
      }
      if (login.defined) {
        this.valueMap.put("login", login.value);
      }
    }

    public Input id() {
      return id;
    }

    public Input login() {
      return login;
    }

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

    @Override
    public InputFieldMarshaller marshaller() {
      return new InputFieldMarshaller() {
        @Override
        public void marshal(InputFieldWriter writer) throws IOException {
          if (id.defined) {
            writer.writeCustom("id", com.github.twitch4j.graphql.internal.type.CustomType.ID, id.value != null ? id.value : null);
          }
          if (login.defined) {
            writer.writeString("login", login.value);
          }
        }
      };
    }
  }

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

    final @Nullable User user;

    private transient volatile String $toString;

    private transient volatile int $hashCode;

    private transient volatile boolean $hashCodeMemoized;

    public Data(@Nullable User user) {
      this.user = user;
    }

    /**
     * Get a user by their ID or login.
     * If no ID or login is provided, null is returned.
     * Lookup type can tell the resolver to include all users (inclusing deleted and
     * suspended accounts) on the lookup, defaults to only retrieve active users.
     */
    public @Nullable User user() {
      return this.user;
    }

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

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

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

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

    public static final class Mapper implements ResponseFieldMapper {
      final User.Mapper userFieldMapper = new User.Mapper();

      @Override
      public Data map(ResponseReader reader) {
        final User user = reader.readObject($responseFields[0], new ResponseReader.ObjectReader() {
          @Override
          public User read(ResponseReader reader) {
            return userFieldMapper.map(reader);
          }
        });
        return new Data(user);
      }
    }
  }

  /**
   * Twitch user.
   */
  public static class User {
    static final ResponseField[] $responseFields = {
      ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()),
      ResponseField.forCustomType("id", "id", null, false, CustomType.ID, Collections.emptyList()),
      ResponseField.forObject("lastBroadcast", "lastBroadcast", null, true, Collections.emptyList())
    };

    final @NotNull String __typename;

    final @NotNull String id;

    final @Nullable LastBroadcast lastBroadcast;

    private transient volatile String $toString;

    private transient volatile int $hashCode;

    private transient volatile boolean $hashCodeMemoized;

    public User(@NotNull String __typename, @NotNull String id,
        @Nullable LastBroadcast lastBroadcast) {
      this.__typename = Utils.checkNotNull(__typename, "__typename == null");
      this.id = Utils.checkNotNull(id, "id == null");
      this.lastBroadcast = lastBroadcast;
    }

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

    /**
     * The user's unique identifier.
     */
    public @NotNull String id() {
      return this.id;
    }

    /**
     * The user's last broadcast.
     */
    public @Nullable LastBroadcast lastBroadcast() {
      return this.lastBroadcast;
    }

    @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.writeObject($responseFields[2], lastBroadcast != null ? lastBroadcast.marshaller() : null);
        }
      };
    }

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

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

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

    public static final class Mapper implements ResponseFieldMapper {
      final LastBroadcast.Mapper lastBroadcastFieldMapper = new LastBroadcast.Mapper();

      @Override
      public User map(ResponseReader reader) {
        final String __typename = reader.readString($responseFields[0]);
        final String id = reader.readCustomType((ResponseField.CustomTypeField) $responseFields[1]);
        final LastBroadcast lastBroadcast = reader.readObject($responseFields[2], new ResponseReader.ObjectReader() {
          @Override
          public LastBroadcast read(ResponseReader reader) {
            return lastBroadcastFieldMapper.map(reader);
          }
        });
        return new User(__typename, id, lastBroadcast);
      }
    }
  }

  /**
   * A historical representation of a live stream.
   */
  public static class LastBroadcast {
    static final ResponseField[] $responseFields = {
      ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()),
      ResponseField.forCustomType("id", "id", null, true, CustomType.ID, Collections.emptyList()),
      ResponseField.forCustomType("startedAt", "startedAt", null, true, CustomType.TIME, Collections.emptyList()),
      ResponseField.forString("title", "title", null, true, Collections.emptyList())
    };

    final @NotNull String __typename;

    final @Nullable String id;

    final @Nullable Object startedAt;

    final @Nullable String title;

    private transient volatile String $toString;

    private transient volatile int $hashCode;

    private transient volatile boolean $hashCodeMemoized;

    public LastBroadcast(@NotNull String __typename, @Nullable String id,
        @Nullable Object startedAt, @Nullable String title) {
      this.__typename = Utils.checkNotNull(__typename, "__typename == null");
      this.id = id;
      this.startedAt = startedAt;
      this.title = title;
    }

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

    /**
     * The broadcast's unique identifier.
     */
    public @Nullable String id() {
      return this.id;
    }

    /**
     * When the broadcast started.
     */
    public @Nullable Object startedAt() {
      return this.startedAt;
    }

    /**
     * The title of the broadcast.
     */
    public @Nullable String title() {
      return this.title;
    }

    @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.writeCustom((ResponseField.CustomTypeField) $responseFields[2], startedAt);
          writer.writeString($responseFields[3], title);
        }
      };
    }

    @Override
    public String toString() {
      if ($toString == null) {
        $toString = "LastBroadcast{"
          + "__typename=" + __typename + ", "
          + "id=" + id + ", "
          + "startedAt=" + startedAt + ", "
          + "title=" + title
          + "}";
      }
      return $toString;
    }

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

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

    public static final class Mapper implements ResponseFieldMapper {
      @Override
      public LastBroadcast map(ResponseReader reader) {
        final String __typename = reader.readString($responseFields[0]);
        final String id = reader.readCustomType((ResponseField.CustomTypeField) $responseFields[1]);
        final Object startedAt = reader.readCustomType((ResponseField.CustomTypeField) $responseFields[2]);
        final String title = reader.readString($responseFields[3]);
        return new LastBroadcast(__typename, id, startedAt, title);
      }
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy