-
Notifications
You must be signed in to change notification settings - Fork 662
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
use proper singularized version of species in the sample #150
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -69,9 +69,9 @@ public final class DroidDetails implements Query<Operation.Variables> { | |
public static class Data implements Operation.Data { | ||
private static final ResponseFieldMapper<Data> MAPPER = new ResponseFieldMapper<Data>() { | ||
private final Field[] FIELDS = { | ||
Field.forObject("species", "species", null, true, new Field.ObjectReader<Specy>() { | ||
@Override public Specy read(final ResponseReader reader) throws IOException { | ||
return new Specy(reader); | ||
Field.forObject("species", "species", null, true, new Field.ObjectReader<Species>() { | ||
@Override public Species read(final ResponseReader reader) throws IOException { | ||
return new Species(reader); | ||
} | ||
}) | ||
}; | ||
|
@@ -83,7 +83,7 @@ public final class DroidDetails implements Query<Operation.Variables> { | |
public void handle(final int fieldIndex, final Object value) throws IOException { | ||
switch (fieldIndex) { | ||
case 0: { | ||
instance.species = (Specy) value; | ||
instance.species = (Species) value; | ||
break; | ||
} | ||
} | ||
|
@@ -92,26 +92,49 @@ public final class DroidDetails implements Query<Operation.Variables> { | |
} | ||
}; | ||
|
||
private @Nullable Specy species; | ||
public static final Creator CREATOR = new Creator() { | ||
@Override | ||
public Data create(@Nullable Species species) { | ||
return new Data(species); | ||
} | ||
}; | ||
|
||
public static final Factory FACTORY = new Factory() { | ||
@Override | ||
public Creator creator() { | ||
return CREATOR; | ||
} | ||
|
||
@Override | ||
public Species.Factory speciesFactory() { | ||
return Species.FACTORY; | ||
} | ||
}; | ||
|
||
private @Nullable Species species; | ||
|
||
public Data(ResponseReader reader) throws IOException { | ||
MAPPER.map(reader, this); | ||
} | ||
|
||
public @Nullable Specy species() { | ||
public Data(@Nullable Species species) { | ||
this.species = species; | ||
} | ||
|
||
public @Nullable Species species() { | ||
return this.species; | ||
} | ||
|
||
public static class Specy { | ||
private static final ResponseFieldMapper<Specy> MAPPER = new ResponseFieldMapper<Specy>() { | ||
public static class Species { | ||
private static final ResponseFieldMapper<Species> MAPPER = new ResponseFieldMapper<Species>() { | ||
private final Field[] FIELDS = { | ||
Field.forString("id", "id", null, false), | ||
Field.forString("name", "name", null, true), | ||
Field.forString("classification", "classification", null, true) | ||
}; | ||
|
||
@Override | ||
public void map(final ResponseReader reader, final Specy instance) throws IOException { | ||
public void map(final ResponseReader reader, final Species instance) throws IOException { | ||
reader.read(new ResponseReader.ValueHandler() { | ||
@Override | ||
public void handle(final int fieldIndex, final Object value) throws IOException { | ||
|
@@ -134,16 +157,37 @@ public final class DroidDetails implements Query<Operation.Variables> { | |
} | ||
}; | ||
|
||
public static final Creator CREATOR = new Creator() { | ||
@Override | ||
public Species create(@Nonnull String id, @Nullable String name, | ||
@Nullable String classification) { | ||
return new Species(id, name, classification); | ||
} | ||
}; | ||
|
||
public static final Factory FACTORY = new Factory() { | ||
@Override | ||
public Creator creator() { | ||
return CREATOR; | ||
} | ||
}; | ||
|
||
private @Nonnull String id; | ||
|
||
private @Nullable String name; | ||
|
||
private @Nullable String classification; | ||
|
||
public Specy(ResponseReader reader) throws IOException { | ||
public Species(ResponseReader reader) throws IOException { | ||
MAPPER.map(reader, this); | ||
} | ||
|
||
public Species(@Nonnull String id, @Nullable String name, @Nullable String classification) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. will get rid of this. I just copied off the generated class. |
||
this.id = id; | ||
this.name = name; | ||
this.classification = classification; | ||
} | ||
|
||
public @Nonnull String id() { | ||
return this.id; | ||
} | ||
|
@@ -155,7 +199,6 @@ public final class DroidDetails implements Query<Operation.Variables> { | |
public @Nullable String classification() { | ||
return this.classification; | ||
} | ||
} | ||
} | ||
} | ||
``` | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ ext { | |
|
||
dep = [ | ||
androidPlugin: 'com.android.tools.build:gradle:2.3.0-beta3', | ||
apolloPlugin: "com.apollographql.android:gradle-plugin:0.1.0", | ||
apolloPlugin: "com.apollographql.android:gradle-plugin:0.2.0-SNAPSHOT", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it worth having some kind of a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not a fan of having development outside of master, we can keep master always pointing to the SNAPSHOTS I think. This shouldn't be pointing to 0.1.0 in the first place There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ahh, fair enough. That solves it. |
||
supportAnnotations: 'com.android.support:support-annotations:25.1.0', | ||
compiletesting: 'com.google.testing.compile:compile-testing:0.10', | ||
javaPoet: 'com.squareup:javapoet:1.8.0', | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will get rid of this too.