package com.example.arguments_simple; import com.apollographql.apollo.api.Field; import com.apollographql.apollo.api.Operation; import com.apollographql.apollo.api.OperationName; import com.apollographql.apollo.api.Query; import com.apollographql.apollo.api.ResponseFieldMapper; import com.apollographql.apollo.api.ResponseReader; import com.apollographql.apollo.api.internal.Optional; import com.apollographql.apollo.api.internal.UnmodifiableMapBuilder; import com.example.arguments_simple.type.Episode; import java.io.IOException; import java.lang.Object; import java.lang.Override; import java.lang.String; import java.util.Collections; import java.util.LinkedHashMap; import java.util.Map; import javax.annotation.Generated; import javax.annotation.Nonnull; import javax.annotation.Nullable; @Generated("Apollo GraphQL") public final class TestQuery implements Query<TestQuery.Data, Optional<TestQuery.Data>, TestQuery.Variables> { public static final String OPERATION_DEFINITION = "query TestQuery($episode: Episode, $includeName: Boolean!) {\n" + " hero(episode: $episode) {\n" + " __typename\n" + " name @include(if: $includeName)\n" + " }\n" + "}"; public static final String QUERY_DOCUMENT = OPERATION_DEFINITION; private static final OperationName OPERATION_NAME = new OperationName() { @Override public String name() { return "TestQuery"; } }; private final TestQuery.Variables variables; public TestQuery(@Nullable Episode episode, boolean includeName) { variables = new TestQuery.Variables(episode, includeName); } @Override public String queryDocument() { return QUERY_DOCUMENT; } @Override public Optional<TestQuery.Data> wrapData(TestQuery.Data data) { return Optional.fromNullable(data); } @Override public TestQuery.Variables variables() { return variables; } @Override public ResponseFieldMapper<TestQuery.Data> responseFieldMapper() { return new Data.Mapper(); } public static Builder builder() { return new Builder(); } @Override public OperationName name() { return OPERATION_NAME; } public static final class Variables extends Operation.Variables { private final @Nullable Episode episode; private final boolean includeName; private final transient Map<String, Object> valueMap = new LinkedHashMap<>(); Variables(@Nullable Episode episode, boolean includeName) { this.episode = episode; this.includeName = includeName; this.valueMap.put("episode", episode); this.valueMap.put("includeName", includeName); } public @Nullable Episode episode() { return episode; } public boolean includeName() { return includeName; } @Override public Map<String, Object> valueMap() { return Collections.unmodifiableMap(valueMap); } } public static final class Builder { private @Nullable Episode episode; private boolean includeName; Builder() { } public Builder episode(@Nullable Episode episode) { this.episode = episode; return this; } public Builder includeName(boolean includeName) { this.includeName = includeName; return this; } public TestQuery build() { return new TestQuery(episode, includeName); } } public static class Data implements Operation.Data { private final Optional<Hero> hero; private volatile String $toString; private volatile int $hashCode; private volatile boolean $hashCodeMemoized; public Data(@Nullable Hero hero) { this.hero = Optional.fromNullable(hero); } public Optional<Hero> hero() { return this.hero; } @Override public String toString() { if ($toString == null) { $toString = "Data{" + "hero=" + hero + "}"; } return $toString; } @Override public boolean equals(Object o) { if (o == this) { return true; } if (o instanceof Data) { Data that = (Data) o; return this.hero.equals(that.hero); } return false; } @Override public int hashCode() { if (!$hashCodeMemoized) { int h = 1; h *= 1000003; h ^= hero.hashCode(); $hashCode = h; $hashCodeMemoized = true; } return $hashCode; } public static final class Mapper implements ResponseFieldMapper<Data> { final Hero.Mapper heroFieldMapper = new Hero.Mapper(); final Field[] fields = { Field.forObject("hero", "hero", new UnmodifiableMapBuilder<String, Object>(1) .put("episode", new UnmodifiableMapBuilder<String, Object>(2) .put("kind", "Variable") .put("variableName", "episode") .build()) .build(), true, new Field.ObjectReader<Hero>() { @Override public Hero read(final ResponseReader reader) throws IOException { return heroFieldMapper.map(reader); } }) }; @Override public Data map(ResponseReader reader) throws IOException { final Hero hero = reader.read(fields[0]); return new Data(hero); } } } public static class Hero { private final @Nonnull String __typename; private final Optional<String> name; private volatile String $toString; private volatile int $hashCode; private volatile boolean $hashCodeMemoized; public Hero(@Nonnull String __typename, @Nullable String name) { this.__typename = __typename; this.name = Optional.fromNullable(name); } public @Nonnull String __typename() { return this.__typename; } /** * The name of the character */ public Optional<String> name() { return this.name; } @Override public String toString() { if ($toString == null) { $toString = "Hero{" + "__typename=" + __typename + ", " + "name=" + name + "}"; } return $toString; } @Override public boolean equals(Object o) { if (o == this) { return true; } if (o instanceof Hero) { Hero that = (Hero) o; return this.__typename.equals(that.__typename) && this.name.equals(that.name); } return false; } @Override public int hashCode() { if (!$hashCodeMemoized) { int h = 1; h *= 1000003; h ^= __typename.hashCode(); h *= 1000003; h ^= name.hashCode(); $hashCode = h; $hashCodeMemoized = true; } return $hashCode; } public static final class Mapper implements ResponseFieldMapper<Hero> { final Field[] fields = { Field.forString("__typename", "__typename", null, false), Field.forString("name", "name", null, true) }; @Override public Hero map(ResponseReader reader) throws IOException { final String __typename = reader.read(fields[0]); final String name = reader.read(fields[1]); return new Hero(__typename, name); } } } }