Skip to content
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

Merged
merged 2 commits into from
Feb 5, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 54 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
})
};
Expand All @@ -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;
}
}
Expand All @@ -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 {
Expand All @@ -134,16 +157,37 @@ public final class DroidDetails implements Query<Operation.Variables> {
}
};

public static final Creator CREATOR = new Creator() {
Copy link
Contributor Author

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.

@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) {
Copy link
Contributor Author

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. I just copied off the generated class.

this.id = id;
this.name = name;
this.classification = classification;
}

public @Nonnull String id() {
return this.id;
}
Expand All @@ -155,7 +199,6 @@ public final class DroidDetails implements Query<Operation.Variables> {
public @Nullable String classification() {
return this.classification;
}
}
}
}
```
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it worth having some kind of a dev branch that we build snapshots off instead and make that our target branch? and keep master for the releases?

Copy link
Contributor

Choose a reason for hiding this comment

The 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

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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',
Expand Down