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

com.github.twitch4j.graphql.internal.FetchActivePredictionsQuery 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.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 com.github.twitch4j.graphql.internal.type.PredictionEventStatus;
import com.github.twitch4j.graphql.internal.type.PredictionOutcomeColor;
import java.io.IOException;
import java.lang.Object;
import java.lang.Override;
import java.lang.String;
import java.lang.SuppressWarnings;
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
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 FetchActivePredictionsQuery implements Query {
  public static final String OPERATION_ID = "b15d5f0eea939431bba4b65a0fb2bceb9c66d213ad72af1ac1573daba4fa0c1d";

  public static final String QUERY_DOCUMENT = QueryDocumentMinifier.minify(
    "query fetchActivePredictions($channelId: ID!) {\n"
        + "  channel(id: $channelId) {\n"
        + "    __typename\n"
        + "    activePredictionEvents {\n"
        + "      __typename\n"
        + "      createdAt\n"
        + "      createdBy {\n"
        + "        __typename\n"
        + "        ... on User {\n"
        + "          id\n"
        + "          displayName\n"
        + "          login\n"
        + "        }\n"
        + "      }\n"
        + "      id\n"
        + "      outcomes {\n"
        + "        __typename\n"
        + "        color\n"
        + "        id\n"
        + "        title\n"
        + "        topPredictors {\n"
        + "          __typename\n"
        + "          id\n"
        + "          points\n"
        + "          predictedAt\n"
        + "          updatedAt\n"
        + "          user {\n"
        + "            __typename\n"
        + "            id\n"
        + "            displayName\n"
        + "            login\n"
        + "          }\n"
        + "        }\n"
        + "        totalPoints\n"
        + "        totalUsers\n"
        + "      }\n"
        + "      predictionWindowSeconds\n"
        + "      status\n"
        + "      title\n"
        + "    }\n"
        + "  }\n"
        + "}"
  );

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

  private final FetchActivePredictionsQuery.Variables variables;

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

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

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

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

  @Override
  public FetchActivePredictionsQuery.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 channelId;

    Builder() {
    }

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

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

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

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

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

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

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

    @Override
    public InputFieldMarshaller marshaller() {
      return new InputFieldMarshaller() {
        @Override
        public void marshal(InputFieldWriter writer) throws IOException {
          writer.writeCustom("channelId", com.github.twitch4j.graphql.internal.type.CustomType.ID, channelId);
        }
      };
    }
  }

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

    final @Nullable Channel channel;

    private transient volatile String $toString;

    private transient volatile int $hashCode;

    private transient volatile boolean $hashCodeMemoized;

    public Data(@Nullable Channel channel) {
      this.channel = channel;
    }

    /**
     * Get a channel by ID or name.
     */
    public @Nullable Channel channel() {
      return this.channel;
    }

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

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

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

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

    public static final class Mapper implements ResponseFieldMapper {
      final Channel.Mapper channelFieldMapper = new Channel.Mapper();

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

  /**
   * A User's place on Twitch.
   */
  public static class Channel {
    static final ResponseField[] $responseFields = {
      ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()),
      ResponseField.forList("activePredictionEvents", "activePredictionEvents", null, true, Collections.emptyList())
    };

    final @NotNull String __typename;

    final @Nullable List activePredictionEvents;

    private transient volatile String $toString;

    private transient volatile int $hashCode;

    private transient volatile boolean $hashCodeMemoized;

    public Channel(@NotNull String __typename,
        @Nullable List activePredictionEvents) {
      this.__typename = Utils.checkNotNull(__typename, "__typename == null");
      this.activePredictionEvents = activePredictionEvents;
    }

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

    /**
     * All Prediction Events that are actively accepting new predictions.
     */
    public @Nullable List activePredictionEvents() {
      return this.activePredictionEvents;
    }

    @SuppressWarnings({"rawtypes", "unchecked"})
    public ResponseFieldMarshaller marshaller() {
      return new ResponseFieldMarshaller() {
        @Override
        public void marshal(ResponseWriter writer) {
          writer.writeString($responseFields[0], __typename);
          writer.writeList($responseFields[1], activePredictionEvents, new ResponseWriter.ListWriter() {
            @Override
            public void write(List items, ResponseWriter.ListItemWriter listItemWriter) {
              for (Object item : items) {
                listItemWriter.writeObject(((ActivePredictionEvent) item).marshaller());
              }
            }
          });
        }
      };
    }

    @Override
    public String toString() {
      if ($toString == null) {
        $toString = "Channel{"
          + "__typename=" + __typename + ", "
          + "activePredictionEvents=" + activePredictionEvents
          + "}";
      }
      return $toString;
    }

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

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

    public static final class Mapper implements ResponseFieldMapper {
      final ActivePredictionEvent.Mapper activePredictionEventFieldMapper = new ActivePredictionEvent.Mapper();

      @Override
      public Channel map(ResponseReader reader) {
        final String __typename = reader.readString($responseFields[0]);
        final List activePredictionEvents = reader.readList($responseFields[1], new ResponseReader.ListReader() {
          @Override
          public ActivePredictionEvent read(ResponseReader.ListItemReader listItemReader) {
            return listItemReader.readObject(new ResponseReader.ObjectReader() {
              @Override
              public ActivePredictionEvent read(ResponseReader reader) {
                return activePredictionEventFieldMapper.map(reader);
              }
            });
          }
        });
        return new Channel(__typename, activePredictionEvents);
      }
    }
  }

  /**
   * An Event that users can make Predictions on.
   */
  public static class ActivePredictionEvent {
    static final ResponseField[] $responseFields = {
      ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()),
      ResponseField.forCustomType("createdAt", "createdAt", null, false, CustomType.TIME, Collections.emptyList()),
      ResponseField.forObject("createdBy", "createdBy", null, true, Collections.emptyList()),
      ResponseField.forCustomType("id", "id", null, false, CustomType.ID, Collections.emptyList()),
      ResponseField.forList("outcomes", "outcomes", null, false, Collections.emptyList()),
      ResponseField.forInt("predictionWindowSeconds", "predictionWindowSeconds", null, false, Collections.emptyList()),
      ResponseField.forString("status", "status", null, false, Collections.emptyList()),
      ResponseField.forString("title", "title", null, false, Collections.emptyList())
    };

    final @NotNull String __typename;

    final @NotNull Object createdAt;

    final @Nullable CreatedBy createdBy;

    final @NotNull String id;

    final @NotNull List outcomes;

    final int predictionWindowSeconds;

    final @NotNull PredictionEventStatus status;

    final @NotNull String title;

    private transient volatile String $toString;

    private transient volatile int $hashCode;

    private transient volatile boolean $hashCodeMemoized;

    public ActivePredictionEvent(@NotNull String __typename, @NotNull Object createdAt,
        @Nullable CreatedBy createdBy, @NotNull String id, @NotNull List outcomes,
        int predictionWindowSeconds, @NotNull PredictionEventStatus status, @NotNull String title) {
      this.__typename = Utils.checkNotNull(__typename, "__typename == null");
      this.createdAt = Utils.checkNotNull(createdAt, "createdAt == null");
      this.createdBy = createdBy;
      this.id = Utils.checkNotNull(id, "id == null");
      this.outcomes = Utils.checkNotNull(outcomes, "outcomes == null");
      this.predictionWindowSeconds = predictionWindowSeconds;
      this.status = Utils.checkNotNull(status, "status == null");
      this.title = Utils.checkNotNull(title, "title == null");
    }

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

    /**
     * The timestamp of when the Event was created.
     */
    public @NotNull Object createdAt() {
      return this.createdAt;
    }

    /**
     * The creator of the Event. Null if the Event was created by an automatic process or an admin.
     */
    public @Nullable CreatedBy createdBy() {
      return this.createdBy;
    }

    /**
     * Unique identifier of the Prediction Event.
     */
    public @NotNull String id() {
      return this.id;
    }

    /**
     * The Outcomes available for predicting in this Event.
     */
    public @NotNull List outcomes() {
      return this.outcomes;
    }

    /**
     * The length of the prediction window (the duration that the Event accepts predictions) in seconds.
     */
    public int predictionWindowSeconds() {
      return this.predictionWindowSeconds;
    }

    /**
     * The current status of the Event.
     */
    public @NotNull PredictionEventStatus status() {
      return this.status;
    }

    /**
     * The title of the Event.
     */
    public @NotNull 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], createdAt);
          writer.writeObject($responseFields[2], createdBy != null ? createdBy.marshaller() : null);
          writer.writeCustom((ResponseField.CustomTypeField) $responseFields[3], id);
          writer.writeList($responseFields[4], outcomes, new ResponseWriter.ListWriter() {
            @Override
            public void write(List items, ResponseWriter.ListItemWriter listItemWriter) {
              for (Object item : items) {
                listItemWriter.writeObject(((Outcome) item).marshaller());
              }
            }
          });
          writer.writeInt($responseFields[5], predictionWindowSeconds);
          writer.writeString($responseFields[6], status.rawValue());
          writer.writeString($responseFields[7], title);
        }
      };
    }

    @Override
    public String toString() {
      if ($toString == null) {
        $toString = "ActivePredictionEvent{"
          + "__typename=" + __typename + ", "
          + "createdAt=" + createdAt + ", "
          + "createdBy=" + createdBy + ", "
          + "id=" + id + ", "
          + "outcomes=" + outcomes + ", "
          + "predictionWindowSeconds=" + predictionWindowSeconds + ", "
          + "status=" + status + ", "
          + "title=" + title
          + "}";
      }
      return $toString;
    }

    @Override
    public boolean equals(Object o) {
      if (o == this) {
        return true;
      }
      if (o instanceof ActivePredictionEvent) {
        ActivePredictionEvent that = (ActivePredictionEvent) o;
        return this.__typename.equals(that.__typename)
         && this.createdAt.equals(that.createdAt)
         && ((this.createdBy == null) ? (that.createdBy == null) : this.createdBy.equals(that.createdBy))
         && this.id.equals(that.id)
         && this.outcomes.equals(that.outcomes)
         && this.predictionWindowSeconds == that.predictionWindowSeconds
         && this.status.equals(that.status)
         && this.title.equals(that.title);
      }
      return false;
    }

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

    public static final class Mapper implements ResponseFieldMapper {
      final CreatedBy.Mapper createdByFieldMapper = new CreatedBy.Mapper();

      final Outcome.Mapper outcomeFieldMapper = new Outcome.Mapper();

      @Override
      public ActivePredictionEvent map(ResponseReader reader) {
        final String __typename = reader.readString($responseFields[0]);
        final Object createdAt = reader.readCustomType((ResponseField.CustomTypeField) $responseFields[1]);
        final CreatedBy createdBy = reader.readObject($responseFields[2], new ResponseReader.ObjectReader() {
          @Override
          public CreatedBy read(ResponseReader reader) {
            return createdByFieldMapper.map(reader);
          }
        });
        final String id = reader.readCustomType((ResponseField.CustomTypeField) $responseFields[3]);
        final List outcomes = reader.readList($responseFields[4], new ResponseReader.ListReader() {
          @Override
          public Outcome read(ResponseReader.ListItemReader listItemReader) {
            return listItemReader.readObject(new ResponseReader.ObjectReader() {
              @Override
              public Outcome read(ResponseReader reader) {
                return outcomeFieldMapper.map(reader);
              }
            });
          }
        });
        final int predictionWindowSeconds = reader.readInt($responseFields[5]);
        final String statusStr = reader.readString($responseFields[6]);
        final PredictionEventStatus status;
        if (statusStr != null) {
          status = PredictionEventStatus.safeValueOf(statusStr);
        } else {
          status = null;
        }
        final String title = reader.readString($responseFields[7]);
        return new ActivePredictionEvent(__typename, createdAt, createdBy, id, outcomes, predictionWindowSeconds, status, title);
      }
    }
  }

  /**
   * Someone or something that is capable of performing actions on a Prediction Event.
   */
  public interface CreatedBy {
    @NotNull String __typename();

    ResponseFieldMarshaller marshaller();

    final class Mapper implements ResponseFieldMapper {
      static final ResponseField[] $responseFields = {
        ResponseField.forFragment("__typename", "__typename", Arrays.asList(
          ResponseField.Condition.typeCondition(new String[] {"User"})
        ))
      };

      final AsUser.Mapper asUserFieldMapper = new AsUser.Mapper();

      final AsPredictionEventActor.Mapper asPredictionEventActorFieldMapper = new AsPredictionEventActor.Mapper();

      @Override
      public CreatedBy map(ResponseReader reader) {
        final AsUser asUser = reader.readFragment($responseFields[0], new ResponseReader.ObjectReader() {
          @Override
          public AsUser read(ResponseReader reader) {
            return asUserFieldMapper.map(reader);
          }
        });
        if (asUser != null) {
          return asUser;
        }
        return asPredictionEventActorFieldMapper.map(reader);
      }
    }
  }

  /**
   * Twitch user.
   */
  public static class AsUser implements CreatedBy {
    static final ResponseField[] $responseFields = {
      ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()),
      ResponseField.forCustomType("id", "id", null, false, CustomType.ID, Collections.emptyList()),
      ResponseField.forString("displayName", "displayName", null, false, Collections.emptyList()),
      ResponseField.forString("login", "login", null, false, Collections.emptyList())
    };

    final @NotNull String __typename;

    final @NotNull String id;

    final @NotNull String displayName;

    final @NotNull String login;

    private transient volatile String $toString;

    private transient volatile int $hashCode;

    private transient volatile boolean $hashCodeMemoized;

    public AsUser(@NotNull String __typename, @NotNull String id, @NotNull String displayName,
        @NotNull String login) {
      this.__typename = Utils.checkNotNull(__typename, "__typename == null");
      this.id = Utils.checkNotNull(id, "id == null");
      this.displayName = Utils.checkNotNull(displayName, "displayName == null");
      this.login = Utils.checkNotNull(login, "login == null");
    }

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

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

    /**
     * A user-styled version of their login.
     * For international users, this could be the user's login with localized characters.
     */
    public @NotNull String displayName() {
      return this.displayName;
    }

    /**
     * The user's standard alphanumeric Twitch name.
     */
    public @NotNull String login() {
      return this.login;
    }

    @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], displayName);
          writer.writeString($responseFields[3], login);
        }
      };
    }

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

    @Override
    public boolean equals(Object o) {
      if (o == this) {
        return true;
      }
      if (o instanceof AsUser) {
        AsUser that = (AsUser) o;
        return this.__typename.equals(that.__typename)
         && this.id.equals(that.id)
         && this.displayName.equals(that.displayName)
         && this.login.equals(that.login);
      }
      return false;
    }

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

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

  /**
   * Someone or something that is capable of performing actions on a Prediction Event.
   */
  public static class AsPredictionEventActor implements CreatedBy {
    static final ResponseField[] $responseFields = {
      ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList())
    };

    final @NotNull String __typename;

    private transient volatile String $toString;

    private transient volatile int $hashCode;

    private transient volatile boolean $hashCodeMemoized;

    public AsPredictionEventActor(@NotNull String __typename) {
      this.__typename = Utils.checkNotNull(__typename, "__typename == null");
    }

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

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

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

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

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

    public static final class Mapper implements ResponseFieldMapper {
      @Override
      public AsPredictionEventActor map(ResponseReader reader) {
        final String __typename = reader.readString($responseFields[0]);
        return new AsPredictionEventActor(__typename);
      }
    }
  }

  /**
   * A single Outcome that users can choose in a Prediction Event.
   */
  public static class Outcome {
    static final ResponseField[] $responseFields = {
      ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()),
      ResponseField.forString("color", "color", null, false, Collections.emptyList()),
      ResponseField.forCustomType("id", "id", null, false, CustomType.ID, Collections.emptyList()),
      ResponseField.forString("title", "title", null, false, Collections.emptyList()),
      ResponseField.forList("topPredictors", "topPredictors", null, false, Collections.emptyList()),
      ResponseField.forInt("totalPoints", "totalPoints", null, false, Collections.emptyList()),
      ResponseField.forInt("totalUsers", "totalUsers", null, false, Collections.emptyList())
    };

    final @NotNull String __typename;

    final @NotNull PredictionOutcomeColor color;

    final @NotNull String id;

    final @NotNull String title;

    final @NotNull List topPredictors;

    final int totalPoints;

    final int totalUsers;

    private transient volatile String $toString;

    private transient volatile int $hashCode;

    private transient volatile boolean $hashCodeMemoized;

    public Outcome(@NotNull String __typename, @NotNull PredictionOutcomeColor color,
        @NotNull String id, @NotNull String title, @NotNull List topPredictors,
        int totalPoints, int totalUsers) {
      this.__typename = Utils.checkNotNull(__typename, "__typename == null");
      this.color = Utils.checkNotNull(color, "color == null");
      this.id = Utils.checkNotNull(id, "id == null");
      this.title = Utils.checkNotNull(title, "title == null");
      this.topPredictors = Utils.checkNotNull(topPredictors, "topPredictors == null");
      this.totalPoints = totalPoints;
      this.totalUsers = totalUsers;
    }

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

    /**
     * The color of this Outcome.
     */
    public @NotNull PredictionOutcomeColor color() {
      return this.color;
    }

    /**
     * The unique identifier of the Prediction Outcome.
     */
    public @NotNull String id() {
      return this.id;
    }

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

    /**
     * The top predictors (sorted by most points spent) of this Outcome. Empty if no users have predicted this Outcome.
     */
    public @NotNull List topPredictors() {
      return this.topPredictors;
    }

    /**
     * The total number of points that have been spent predicting this Outcome.
     */
    public int totalPoints() {
      return this.totalPoints;
    }

    /**
     * The total number of users that have predicted this Outcome.
     */
    public int totalUsers() {
      return this.totalUsers;
    }

    @SuppressWarnings({"rawtypes", "unchecked"})
    public ResponseFieldMarshaller marshaller() {
      return new ResponseFieldMarshaller() {
        @Override
        public void marshal(ResponseWriter writer) {
          writer.writeString($responseFields[0], __typename);
          writer.writeString($responseFields[1], color.rawValue());
          writer.writeCustom((ResponseField.CustomTypeField) $responseFields[2], id);
          writer.writeString($responseFields[3], title);
          writer.writeList($responseFields[4], topPredictors, new ResponseWriter.ListWriter() {
            @Override
            public void write(List items, ResponseWriter.ListItemWriter listItemWriter) {
              for (Object item : items) {
                listItemWriter.writeObject(((TopPredictor) item).marshaller());
              }
            }
          });
          writer.writeInt($responseFields[5], totalPoints);
          writer.writeInt($responseFields[6], totalUsers);
        }
      };
    }

    @Override
    public String toString() {
      if ($toString == null) {
        $toString = "Outcome{"
          + "__typename=" + __typename + ", "
          + "color=" + color + ", "
          + "id=" + id + ", "
          + "title=" + title + ", "
          + "topPredictors=" + topPredictors + ", "
          + "totalPoints=" + totalPoints + ", "
          + "totalUsers=" + totalUsers
          + "}";
      }
      return $toString;
    }

    @Override
    public boolean equals(Object o) {
      if (o == this) {
        return true;
      }
      if (o instanceof Outcome) {
        Outcome that = (Outcome) o;
        return this.__typename.equals(that.__typename)
         && this.color.equals(that.color)
         && this.id.equals(that.id)
         && this.title.equals(that.title)
         && this.topPredictors.equals(that.topPredictors)
         && this.totalPoints == that.totalPoints
         && this.totalUsers == that.totalUsers;
      }
      return false;
    }

    @Override
    public int hashCode() {
      if (!$hashCodeMemoized) {
        int h = 1;
        h *= 1000003;
        h ^= __typename.hashCode();
        h *= 1000003;
        h ^= color.hashCode();
        h *= 1000003;
        h ^= id.hashCode();
        h *= 1000003;
        h ^= title.hashCode();
        h *= 1000003;
        h ^= topPredictors.hashCode();
        h *= 1000003;
        h ^= totalPoints;
        h *= 1000003;
        h ^= totalUsers;
        $hashCode = h;
        $hashCodeMemoized = true;
      }
      return $hashCode;
    }

    public static final class Mapper implements ResponseFieldMapper {
      final TopPredictor.Mapper topPredictorFieldMapper = new TopPredictor.Mapper();

      @Override
      public Outcome map(ResponseReader reader) {
        final String __typename = reader.readString($responseFields[0]);
        final String colorStr = reader.readString($responseFields[1]);
        final PredictionOutcomeColor color;
        if (colorStr != null) {
          color = PredictionOutcomeColor.safeValueOf(colorStr);
        } else {
          color = null;
        }
        final String id = reader.readCustomType((ResponseField.CustomTypeField) $responseFields[2]);
        final String title = reader.readString($responseFields[3]);
        final List topPredictors = reader.readList($responseFields[4], new ResponseReader.ListReader() {
          @Override
          public TopPredictor read(ResponseReader.ListItemReader listItemReader) {
            return listItemReader.readObject(new ResponseReader.ObjectReader() {
              @Override
              public TopPredictor read(ResponseReader reader) {
                return topPredictorFieldMapper.map(reader);
              }
            });
          }
        });
        final int totalPoints = reader.readInt($responseFields[5]);
        final int totalUsers = reader.readInt($responseFields[6]);
        return new Outcome(__typename, color, id, title, topPredictors, totalPoints, totalUsers);
      }
    }
  }

  /**
   * A single Prediction made by a user on a Prediction Event.
   */
  public static class TopPredictor {
    static final ResponseField[] $responseFields = {
      ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()),
      ResponseField.forCustomType("id", "id", null, false, CustomType.ID, Collections.emptyList()),
      ResponseField.forInt("points", "points", null, false, Collections.emptyList()),
      ResponseField.forCustomType("predictedAt", "predictedAt", null, false, CustomType.TIME, Collections.emptyList()),
      ResponseField.forCustomType("updatedAt", "updatedAt", null, false, CustomType.TIME, Collections.emptyList()),
      ResponseField.forObject("user", "user", null, true, Collections.emptyList())
    };

    final @NotNull String __typename;

    final @NotNull String id;

    final int points;

    final @NotNull Object predictedAt;

    final @NotNull Object updatedAt;

    final @Nullable User user;

    private transient volatile String $toString;

    private transient volatile int $hashCode;

    private transient volatile boolean $hashCodeMemoized;

    public TopPredictor(@NotNull String __typename, @NotNull String id, int points,
        @NotNull Object predictedAt, @NotNull Object updatedAt, @Nullable User user) {
      this.__typename = Utils.checkNotNull(__typename, "__typename == null");
      this.id = Utils.checkNotNull(id, "id == null");
      this.points = points;
      this.predictedAt = Utils.checkNotNull(predictedAt, "predictedAt == null");
      this.updatedAt = Utils.checkNotNull(updatedAt, "updatedAt == null");
      this.user = user;
    }

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

    /**
     * The unique identifier of the Prediction.
     */
    public @NotNull String id() {
      return this.id;
    }

    /**
     * The number of points that the user spent on this Prediction.
     */
    public int points() {
      return this.points;
    }

    /**
     * The timestamp of when the user initially made this Prediction.
     */
    public @NotNull Object predictedAt() {
      return this.predictedAt;
    }

    /**
     * The timestamp of when the user most recently updated this Prediction.
     */
    public @NotNull Object updatedAt() {
      return this.updatedAt;
    }

    /**
     * The user that made this Prediction.
     */
    public @Nullable User user() {
      return this.user;
    }

    @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.writeInt($responseFields[2], points);
          writer.writeCustom((ResponseField.CustomTypeField) $responseFields[3], predictedAt);
          writer.writeCustom((ResponseField.CustomTypeField) $responseFields[4], updatedAt);
          writer.writeObject($responseFields[5], user != null ? user.marshaller() : null);
        }
      };
    }

    @Override
    public String toString() {
      if ($toString == null) {
        $toString = "TopPredictor{"
          + "__typename=" + __typename + ", "
          + "id=" + id + ", "
          + "points=" + points + ", "
          + "predictedAt=" + predictedAt + ", "
          + "updatedAt=" + updatedAt + ", "
          + "user=" + user
          + "}";
      }
      return $toString;
    }

    @Override
    public boolean equals(Object o) {
      if (o == this) {
        return true;
      }
      if (o instanceof TopPredictor) {
        TopPredictor that = (TopPredictor) o;
        return this.__typename.equals(that.__typename)
         && this.id.equals(that.id)
         && this.points == that.points
         && this.predictedAt.equals(that.predictedAt)
         && this.updatedAt.equals(that.updatedAt)
         && ((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 ^= __typename.hashCode();
        h *= 1000003;
        h ^= id.hashCode();
        h *= 1000003;
        h ^= points;
        h *= 1000003;
        h ^= predictedAt.hashCode();
        h *= 1000003;
        h ^= updatedAt.hashCode();
        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 TopPredictor map(ResponseReader reader) {
        final String __typename = reader.readString($responseFields[0]);
        final String id = reader.readCustomType((ResponseField.CustomTypeField) $responseFields[1]);
        final int points = reader.readInt($responseFields[2]);
        final Object predictedAt = reader.readCustomType((ResponseField.CustomTypeField) $responseFields[3]);
        final Object updatedAt = reader.readCustomType((ResponseField.CustomTypeField) $responseFields[4]);
        final User user = reader.readObject($responseFields[5], new ResponseReader.ObjectReader() {
          @Override
          public User read(ResponseReader reader) {
            return userFieldMapper.map(reader);
          }
        });
        return new TopPredictor(__typename, id, points, predictedAt, updatedAt, 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.forString("displayName", "displayName", null, false, Collections.emptyList()),
      ResponseField.forString("login", "login", null, false, Collections.emptyList())
    };

    final @NotNull String __typename;

    final @NotNull String id;

    final @NotNull String displayName;

    final @NotNull String login;

    private transient volatile String $toString;

    private transient volatile int $hashCode;

    private transient volatile boolean $hashCodeMemoized;

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

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

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

    /**
     * A user-styled version of their login.
     * For international users, this could be the user's login with localized characters.
     */
    public @NotNull String displayName() {
      return this.displayName;
    }

    /**
     * The user's standard alphanumeric Twitch name.
     */
    public @NotNull String login() {
      return this.login;
    }

    @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], displayName);
          writer.writeString($responseFields[3], login);
        }
      };
    }

    @Override
    public String toString() {
      if ($toString == null) {
        $toString = "User{"
          + "__typename=" + __typename + ", "
          + "id=" + id + ", "
          + "displayName=" + displayName + ", "
          + "login=" + login
          + "}";
      }
      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.displayName.equals(that.displayName)
         && this.login.equals(that.login);
      }
      return false;
    }

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

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy