Skip to content

Instantly share code, notes, and snippets.

@agustarc
Created January 6, 2017 14:04
Show Gist options
  • Save agustarc/550a16a0bbcde81aeb4466700cc91a13 to your computer and use it in GitHub Desktop.
Save agustarc/550a16a0bbcde81aeb4466700cc91a13 to your computer and use it in GitHub Desktop.
@AutoValue
public abstract class Product {
@SerializedName("id")
public abstract long getId();
@SerializedName("name")
public abstract String getName();
@SerializedName("price")
public abstract float getPrice();
public static TypeAdapter<Product> typeAdapter(Gson gson) {
return new AutoValue_Product.GsonTypeAdapter(gson);
}
public static Product create(long id, String name, float price) {
return new AutoValue_Product(id, name, price);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment