Slide 1

Slide 1 text

Jake Wharton AutoValue Extensions

Slide 2

Slide 2 text

Value Types?

Slide 3

Slide 3 text

Value Types? • Everything is mutable in Java.

Slide 4

Slide 4 text

Value Types? • Basically everything is mutable in Java.

Slide 5

Slide 5 text

Value Types? • Basically everything is mutable in Java. • "Beans" with getters and setters

Slide 6

Slide 6 text

Value Types? • Basically everything is mutable in Java. • "Beans" with getters and setters • Collections

Slide 7

Slide 7 text

Value Types? • Basically everything is mutable in Java. • "Beans" with getters and setters • Collections • Arrays

Slide 8

Slide 8 text

Value Types? • Basically everything is mutable in Java. • "Beans" with getters and setters • Collections • Arrays • Mutator methods

Slide 9

Slide 9 text

Value Types? • Basically everything is mutable in Java. • "Beans" with getters and setters • Collections • Arrays • Mutator methods • Non-scalar "constants"

Slide 10

Slide 10 text

Value Types public class Payment {
 public long id();
 public long amount();
 public String note();
 }X

Slide 11

Slide 11 text

Value Types public final class Payment {
 public long id();
 public long amount();
 public String note();
 }X

Slide 12

Slide 12 text

Value Types public final class Payment {
 private final long id;
 
 public long id() {
 return id;
 }Y
 public long amount();
 public String note();
 }X

Slide 13

Slide 13 text

Value Types public final class Payment {
 private final long id;
 private final long amount;
 
 public long id() {
 return id;
 }Y
 public long amount() {
 return amount;
 }Z
 public String note();
 }X

Slide 14

Slide 14 text

Value Types public final class Payment {
 private final long id;
 private final long amount;
 private final String note;
 
 public long id() {
 return id;
 }Y
 public long amount() {
 return amount;
 }Z
 public String note() {
 return note;
 }W
 }X

Slide 15

Slide 15 text

Value Types public final class Payment {
 private final long id;
 private final long amount;
 private final String note;
 
 public Payment(long id, long amount, String note) {
 this.id = id;
 this.amount = amount;
 this.note = note;
 }Q
 
 public long id() {
 return id;
 }Y
 public long amount() {
 return amount;
 }Z
 public String note() {
 return note;
 }W
 }X

Slide 16

Slide 16 text

Value Types public final class Payment {
 private final long id;
 private final long amount;
 private final String note;
 
 public Payment(long id, long amount, String note) {
 this.id = id;
 this.amount = amount;
 this.note = note;
 }Q
 
 public long id() {
 return id;
 }Y
 public long amount() {
 return amount;
 }Z
 public String note() {
 return note;
 }W
 
 @Override public String toString() {
 return "Payment{" +
 "id=" + id +
 ", amount=" + amount +
 ", note='" + note + '\'' +
 '}';
 }E
 }X

Slide 17

Slide 17 text

Value Types public final class Payment {
 private final long id;
 private final long amount;
 private final String note;
 
 public Payment(long id, long amount, String note) {
 this.id = id;
 this.amount = amount;
 this.note = note;
 }Q
 
 public long id() {
 return id;
 }Y
 public long amount() {
 return amount;
 }Z
 public String note() {
 return note;
 }W
 
 @Override public String toString() {
 return "Payment{" +
 "id=" + id +
 ", amount=" + amount +
 ", note='" + note + '\'' +
 '}';
 }E
 
 @Override public boolean equals(Object o) {
 if (this == o) return true;
 if (!(o instanceof Payment)) return false;
 Payment other = (Payment) o;
 return id == other.id
 && amount == other.amount
 && note.equals(other.note);
 }R
 
 @Override public int hashCode() {
 int result = (int) (id ^ (id >>> 32));
 result = 31 * result + (int) (amount ^ (amount >>> 32));
 result = 31 * result + note.hashCode();
 return result;
 }T
 }X

Slide 18

Slide 18 text

Value Types public final class Payment {
 private final long id;
 private final long amount;
 private final String note;
 
 public Payment(long id, long amount, String note) {
 this.id = id;
 this.amount = amount;
 this.note = note;
 }Q
 
 public long id() {
 return id;
 }Y
 public long amount() {
 return amount;
 }Z
 public String note() {
 return note;
 }W
 
 @Override public String toString() {
 return "Payment{" +
 "id=" + id +
 ", amount=" + amount +
 ", note='" + note + '\'' +
 '}';
 }E
 
 @Override public boolean equals(Object o) {
 if (this == o) return true;
 if (!(o instanceof Payment)) return false;
 Payment other = (Payment) o;
 return id == other.id
 && amount == other.amount
 && note.equals(other.note);
 }R
 
 @Override public int hashCode() {
 int result = (int) (id ^ (id >>> 32));
 result = 31 * result + (int) (amount ^ (amount >>> 32));
 result = 31 * result + note.hashCode();
 return result;
 }T
 }X public Currency currency();

Slide 19

Slide 19 text

Value Types public final class Payment {
 private final long id;
 private final long amount;
 private final Currency currency;
 private final String note;
 
 public Payment(long id, long amount, Currency currency, String note) {
 this.id = id;
 this.amount = amount;
 this.currency = currency;
 this.note = note;
 }Q
 
 public long id() {
 return id;
 }Y
 public long amount() {
 return amount;
 }Z
 public Currency currency() {
 return currency;
 }U
 public String note() {
 return note;
 }W
 
 @Override public String toString() {
 return "Payment{" +
 "id=" + id +
 ", amount=" + amount +
 ", currency=" + currency +
 ", note='" + note + '\'' +
 '}';
 }E
 
 @Override public boolean equals(Object o) {
 if (this == o) return true;
 if (!(o instanceof Payment)) return false;
 Payment other = (Payment) o;
 return id == other.id
 && amount == other.amount
 && currency.equals(other.currency)
 && note.equals(other.note);
 }R
 
 @Override public int hashCode() {
 int result = (int) (id ^ (id >>> 32));
 result = 31 * result + (int) (amount ^ (amount >>> 32));
 result = 31 * result + currency.hashCode();
 result = 31 * result + note.hashCode();
 return result;
 }T
 }X

Slide 20

Slide 20 text

Value Types public final class Payment {
 private final long id;
 private final long amount;
 private final Currency currency;
 private final String note;
 
 public Payment(long id, long amount, Currency currency, String note) {
 this.id = id;
 this.amount = amount;
 this.currency = currency;
 this.note = note;
 }Q
 
 public long id() {
 return id;
 }Y
 public long amount() {
 return amount;
 }Z
 public Currency currency() {
 return currency;
 }U
 public String note() {
 return note;
 }W
 
 @Override public String toString() {
 return "Payment{" +
 "id=" + id +
 ", amount=" + amount +
 ", currency=" + currency +
 ", note='" + note + '\'' +
 '}';
 }E
 
 @Override public boolean equals(Object o) {
 if (this == o) return true;
 if (!(o instanceof Payment)) return false;
 Payment other = (Payment) o;
 return id == other.id
 && amount == other.amount
 && currency.equals(other.currency)
 && note.equals(other.note);
 }R
 
 @Override public int hashCode() {
 int result = (int) (id ^ (id >>> 32));
 result = 31 * result + (int) (amount ^ (amount >>> 32));
 result = 31 * result + currency.hashCode();
 result = 31 * result + note.hashCode();
 return result;
 }T
 }X 1 2 3 4 5 6 7 8 Field Constructor Parameter Constructor Statement Method Signature Method Statement toString() Expression equals() Expression hashCode() Expression

Slide 21

Slide 21 text

Value Types public final class Payment {
 private final long id;
 private final long amount;
 private final Currency currency;
 private final String note;
 
 public Payment(long id, long amount, Currency currency, String note) {
 this.id = id;
 this.amount = amount;
 this.currency = currency;
 this.note = note;
 }Q
 
 public long id() {
 return id;
 }Y
 public long amount() {
 return amount;
 }Z
 public Currency currency() {
 return currency;
 }U
 public String note() {
 return note;
 }W
 
 @Override public String toString() {
 return "Payment{" +
 "id=" + id +
 ", amount=" + amount +
 ", currency=" + currency +
 ", note='" + note + '\'' +
 '}';
 }E
 
 @Override public boolean equals(Object o) {
 if (this == o) return true;
 if (!(o instanceof Payment)) return false;
 Payment other = (Payment) o;
 return id == other.id
 && amount == other.amount
 && currency.equals(other.currency)
 && note.equals(other.note);
 }R
 
 @Override public int hashCode() {
 int result = (int) (id ^ (id >>> 32));
 result = 31 * result + (int) (amount ^ (amount >>> 32));
 result = 31 * result + currency.hashCode();
 result = 31 * result + note.hashCode();
 return result;
 }T
 }X

Slide 22

Slide 22 text

Value Types public final class Payment {
 private final long id;
 private final long amount;
 private final Currency currency;
 private final String note;
 
 public Payment(long id, long amount, Currency currency, String note) {
 this.id = id;
 this.amount = amount;
 this.currency = currency;
 this.note = note;
 }Q
 
 public long id() {
 return id;
 }Y
 public long amount() {
 return amount;
 }Z
 public Currency currency() {
 return currency;
 }U
 public String note() {
 return note;
 }W
 
 @Override public String toString() {
 return "Payment{" +
 "id=" + id +
 ", amount=" + amount +
 ", currency=" + currency +
 ", note='" + note + '\'' +
 '}';
 }E
 
 @Override public boolean equals(Object o) {
 if (this == o) return true;
 if (!(o instanceof Payment)) return false;
 Payment other = (Payment) o;
 return id == other.id
 && amount == other.amount
 && currency.equals(other.currency)
 && note.equals(other.note);
 }R
 
 @Override public int hashCode() {
 int result = (int) (id ^ (id >>> 32));
 result = 31 * result + (int) (amount ^ (amount >>> 32));
 result = 31 * result + currency.hashCode();
 result = 31 * result + note.hashCode();
 return result;
 }T
 }X public class Payment {
 public long id();
 public long amount();
 public Currency currency();
 public String note();
 }X

Slide 23

Slide 23 text

AutoValue! public class Payment {
 public long id();
 public long amount();
 public Currency currency();
 public String note();
 }X

Slide 24

Slide 24 text

AutoValue! @AutoValue public class Payment {
 public long id();
 public long amount();
 public Currency currency();
 public String note();
 }X

Slide 25

Slide 25 text

AutoValue! @AutoValue public abstract class Payment {
 public abstract long id();
 public abstract long amount();
 public abstract Currency currency();
 public abstract String note();
 }X

Slide 26

Slide 26 text

AutoValue! @AutoValue
 public abstract class Payment { 
 public static Payment create(
 long id, long amount, Currency currency, String note) {
 return new AutoValue_Payment(id, amount, currency, note);
 }Z
 
 public abstract long id();
 public abstract long amount();
 public abstract Currency currency();
 public abstract String note();
 }X

Slide 27

Slide 27 text

AutoValue! @AutoValue
 public abstract class Payment { 
 public static Payment create(
 long id, long amount, Currency currency, String note) {
 return new AutoValue_Payment(id, amount, currency, note);
 }Z
 
 public abstract long id();
 public abstract long amount();
 public abstract Currency currency();
 public abstract String note();
 }X

Slide 28

Slide 28 text

AutoValue! @AutoValue
 public abstract class Payment { 
 public static Payment create(
 long id, long amount, Currency currency, String note) {
 return new AutoValue_Payment(id, amount, currency, note);
 }Z
 
 public abstract long id();
 public abstract long amount();
 public abstract Currency currency();
 public abstract String note();
 }X final class AutoValue_Payment extends Payment {
 private final long id;
 private final long amount;
 private final Currency currency;
 private final String note;
 
 AutoValue_Payment(long id, long amount, Currency currency, String note) {
 this.id = id;
 this.amount = amount;
 this.currency = currency;
 this.note = note;
 }Q
 
 @Override public long id() {
 return id;
 }Y
 @Override public long amount() {
 return amount;
 }Z
 @Override public Currency currency() {
 return currency;
 }U
 @Override public String note() {
 return note;
 }W
 
 @Override public String toString() {
 return "Payment{" +
 "id=" + id +
 ", amount=" + amount +
 ", currency=" + currency +
 ", note='" + note + '\'' +
 '}';
 }E
 
 @Override public boolean equals(Object o) {
 if (this == o) return true;
 if (!(o instanceof Payment)) return false;
 Payment other = (Payment) o;
 return id == other.id
 && amount == other.amount
 && currency.equals(other.currency)
 && note.equals(other.note);
 }R
 
 @Override public int hashCode() {
 int result = (int) (id ^ (id >>> 32));
 result = 31 * result + (int) (amount ^ (amount >>> 32));
 result = 31 * result + currency.hashCode();
 result = 31 * result + note.hashCode();
 return result;
 }T
 }X

Slide 29

Slide 29 text

AutoValue! github.com/google/auto

Slide 30

Slide 30 text

AutoValue Extensions @AutoValue public abstract class Payment {
 public abstract long id();
 public abstract long amount();
 public abstract Currency currency();
 public abstract String note();
 }X

Slide 31

Slide 31 text

AutoValue Extensions @AutoValue public abstract class Payment {
 public abstract long id();
 public abstract long amount();
 public abstract Currency currency();
 public abstract String note();
 }X Ok, awesome! Now how do I use it with ? Parcelable

Slide 32

Slide 32 text

AutoValue Extensions @AutoValue public abstract class Payment {
 public abstract long id();
 public abstract long amount();
 public abstract Currency currency();
 public abstract String note();
 }X Ok, awesome! Now how do I use it with ? Parcelable Gson

Slide 33

Slide 33 text

AutoValue Extensions @AutoValue public abstract class Payment {
 public abstract long id();
 public abstract long amount();
 public abstract Currency currency();
 public abstract String note();
 }X Ok, awesome! Now how do I use it with ? Parcelable Gson Cursors

Slide 34

Slide 34 text

AutoValue Extensions @AutoValue public abstract class Payment {
 public abstract long id();
 public abstract long amount();
 public abstract Currency currency();
 public abstract String note();
 }X Ok, awesome! Now how do I use it with ? Parcelable Gson Cursors (whatever)

Slide 35

Slide 35 text

AutoValue Extensions @AutoValue public abstract class Payment {
 public abstract long id();
 public abstract long amount();
 public abstract Currency currency();
 public abstract String note();
 }X Ok, awesome! Now how do I use it with ? Parcelable Gson Cursors (whatever)

Slide 36

Slide 36 text

AutoValue Extensions @AutoValue public abstract class Payment3{
 public abstract long id();
 public abstract long amount();
 public abstract Currency currency();
 public abstract String note();
 }X

Slide 37

Slide 37 text

AutoValue Extensions @AutoValue public abstract class Payment1implements2Parcelable3{3
 public abstract long id();
 public abstract long amount();
 public abstract Currency currency();
 public abstract String note();
 }X /* abstract properties */

Slide 38

Slide 38 text

AutoValue Extensions @AutoValue public abstract class Payment1implements2Parcelable3{3 /* abstract properties */ }X final class AutoValue_Payment1extends2Payment { /* value type implementation */ }Y

Slide 39

Slide 39 text

AutoValue Extensions final class AutoValue_Payment1extends2$AutoValue_Payment { /* parcelable implementation */ }Z abstract class $AutoValue_Payment1extends2Payment { /* value type implementation */ }Y @AutoValue public abstract class Payment1implements2Parcelable { /* abstract properties */ }X

Slide 40

Slide 40 text

final class AutoValue_Payment1extends2$AutoValue_Payment { /* parcelable implementation */ }Z /* abstract properties */ abstract class $AutoValue_Payment1extends2Payment { /* value type implementation */ }Y AutoValue Extensions @AutoValue public abstract class Payment1implements2Parcelable3{3
 public abstract long id();
 public abstract long amount();
 public abstract Currency currency();
 public abstract String note();
 }X /* abstract properties */

Slide 41

Slide 41 text

final class AutoValue_Payment1extends2$AutoValue_Payment { /* parcelable implementation */ }Z /* abstract properties */ abstract class $AutoValue_Payment1extends2Payment { /* value type implementation */ }Y AutoValue Extensions @AutoValue public abstract class Payment1implements2Parcelable3{3
 public abstract long id();
 public abstract long amount();
 public abstract Currency currency();
 @Redacted public abstract String note();
 }X /* abstract properties */

Slide 42

Slide 42 text

AutoValue Extensions final class AutoValue_Payment1extends2$AutoValue_Payment { /* parcelable implementation */ }Z abstract class $AutoValue_Payment1extends2Payment { /* value type implementation */ }Y @AutoValue public abstract class Payment1implements2Parcelable { /* abstract properties */ }X

Slide 43

Slide 43 text

AutoValue Extensions final class AutoValue_Payment1extends2$AutoValue_Payment { /* parcelable implementation */ }Z abstract class $AutoValue_Payment1extends2$$AutoValue_Payment { /* value type implementation (without toString) */ }Y abstract class $$AutoValue_Payment1extends2Payment { /* redacted toString implementation */ }Y @AutoValue public abstract class Payment1implements2Parcelable { /* abstract properties */ }X

Slide 44

Slide 44 text

AutoValue Extensions final class AutoValue_Payment1extends2$AutoValue_Payment { /* parcelable implementation */ }Z abstract class $AutoValue_Payment1extends2$$AutoValue_Payment { /* value type implementation (without toString) */ }Y abstract class $$AutoValue_Payment1extends2Payment { /* redacted toString implementation */ }Y @AutoValue public abstract class Payment1implements2Parcelable { /* abstract properties */ }X

Slide 45

Slide 45 text

AutoValue Extensions final class AutoValue_Payment1extends2$AutoValue_Payment { /* parcelable implementation */ }Z abstract class $AutoValue_Payment1extends2$$AutoValue_Payment { /* value type implementation (without toString) */ }Y abstract class $$AutoValue_Payment1extends2Payment { /* redacted toString implementation */ }Y @AutoValue public abstract class Payment1implements2Parcelable { /* abstract properties */ }X

Slide 46

Slide 46 text

AutoValue Extensions final class AutoValue_Payment1extends2$AutoValue_Payment { /* parcelable implementation */ }Z abstract class $AutoValue_Payment1extends2$$AutoValue_Payment { /* value type implementation (without toString) */ }Y abstract class $$AutoValue_Payment1extends2Payment { /* redacted toString implementation */ }Y @AutoValue public abstract class Payment1implements2Parcelable { /* abstract properties */ }X

Slide 47

Slide 47 text

AutoValue Extensions final class AutoValue_Payment1extends2$AutoValue_Payment { /* parcelable implementation */ }Z abstract class $AutoValue_Payment1extends2$$AutoValue_Payment { /* value type implementation (without toString) */ }Y abstract class $$AutoValue_Payment1extends2Payment { /* redacted toString implementation */ }Y @AutoValue public abstract class Payment1implements2Parcelable { /* abstract properties */ }X

Slide 48

Slide 48 text

Available Extensions

Slide 49

Slide 49 text

Available Extensions • Parcelable: github.com/rharter/auto-value-parcel • Redacted: github.com/square/auto-value-redacted • Gson: github.com/rharter/auto-value-gson • Moshi: github.com/rharter/auto-value-moshi • Cursor: github.com/gabrielittner/auto-value-cursor • "with"ers: github.com/gabrielittner/auto-value-with

Slide 50

Slide 50 text

Extension API

Slide 51

Slide 51 text

Extension API public abstract class AutoValueExtension {
 public boolean applicable(Context context) {
 return false;
 }
 
 public boolean mustBeFinal(Context context) {
 return false;
 }
 
 public Set consumeProperties(Context context) {
 return Collections.emptySet();
 }
 
 public abstract String generateClass(Context context, String className, String classToExtend, boolean isFinal);
 }

Slide 52

Slide 52 text

Extension API public abstract class AutoValueExtension {
 public boolean applicable(Context context) {
 return false;
 }X
 
 public boolean mustBeFinal(Context context) {
 return false;
 }
 
 public Set consumeProperties(Context context) {
 return Collections.emptySet();
 }
 
 public abstract String generateClass(Context context, String className, String classToExtend, boolean isFinal);
 }

Slide 53

Slide 53 text

Extension API public boolean applicable(Context context)

Slide 54

Slide 54 text

Extension API public boolean applicable(Context context) Parcelable extension @AutoValue public abstract class Payment {}

Slide 55

Slide 55 text

Extension API public boolean applicable(Context context) Parcelable extension @AutoValue public abstract class Payment {} false

Slide 56

Slide 56 text

Extension API public boolean applicable(Context context) Parcelable extension Parcelable extension @AutoValue public abstract class Payment {} @AutoValue public abstract class Payment implements Parcelable {} false

Slide 57

Slide 57 text

Extension API public boolean applicable(Context context) Parcelable extension Parcelable extension @AutoValue public abstract class Payment {} @AutoValue public abstract class Payment implements Parcelable {} false true

Slide 58

Slide 58 text

Extension API public boolean applicable(Context context) Parcelable extension Parcelable extension Redacted extension @AutoValue public abstract class Payment {} @AutoValue public abstract class Payment implements Parcelable {} @AutoValue public abstract class Payment { public abstract String note(); } false true

Slide 59

Slide 59 text

Extension API public boolean applicable(Context context) Parcelable extension Parcelable extension Redacted extension @AutoValue public abstract class Payment {} @AutoValue public abstract class Payment implements Parcelable {} @AutoValue public abstract class Payment { public abstract String note(); } false true false

Slide 60

Slide 60 text

Extension API public boolean applicable(Context context) Parcelable extension Parcelable extension Redacted extension Redacted extension @AutoValue public abstract class Payment {} @AutoValue public abstract class Payment implements Parcelable {} @AutoValue public abstract class Payment { public abstract String note(); } @AutoValue public abstract class Payment { @Redacted public abstract String note(); } false true false

Slide 61

Slide 61 text

Extension API public boolean applicable(Context context) Parcelable extension Parcelable extension Redacted extension Redacted extension @AutoValue public abstract class Payment {} @AutoValue public abstract class Payment implements Parcelable {} @AutoValue public abstract class Payment { public abstract String note(); } @AutoValue public abstract class Payment { @Redacted public abstract String note(); } false true false true

Slide 62

Slide 62 text

Extension API public boolean applicable(Context context) false true

Slide 63

Slide 63 text

Extension API public boolean applicable(Context context) false true final class AutoValue_Payment1extends2Payment { /* value type implementation */ }Y @AutoValue public abstract class Payment1{3 /* abstract properties */ }X final class AutoValue_Payment1extends2$AutoValue_Payment { /* value type implementation */ }Y abstract class $AutoValue_Payment1extends2Payment { /* extension implementation */ }Y @AutoValue public abstract class Payment1{3 /* abstract properties */ }X

Slide 64

Slide 64 text

Extension API public abstract class AutoValueExtension {
 public boolean applicable(Context context) {
 return false;
 }X
 
 public boolean mustBeFinal(Context context) {
 return false;
 }
 
 public Set consumeProperties(Context context) {
 return Collections.emptySet();
 }
 
 public abstract String generateClass(Context context, String className, String classToExtend, boolean isFinal);
 }

Slide 65

Slide 65 text

Extension API public abstract class AutoValueExtension {
 public boolean applicable(Context context) {
 return false;
 }
 
 public boolean mustBeFinal(Context context) {
 return false;
 }
 
 public Set consumeProperties(Context context) {
 return Collections.emptySet();
 }
 
 public abstract String generateClass(Context context, String className, String classToExtend, boolean isFinal);
 }

Slide 66

Slide 66 text

Extension API public boolean mustBeFinal(Context context)

Slide 67

Slide 67 text

Extension API public boolean mustBeFinal(Context context) Parcelable extension true

Slide 68

Slide 68 text

Extension API public boolean mustBeFinal(Context context) Parcelable extension true All* other extensions false

Slide 69

Slide 69 text

Extension API public boolean mustBeFinal(Context context) false true

Slide 70

Slide 70 text

Extension API public boolean mustBeFinal(Context context) false true final class AutoValue_Payment1extends2$AutoValue_Payment { /* extension implementation */ }Y abstract class $AutoValue_Payment1extends2Payment { /* value type implementation */ }Y @AutoValue public abstract class Payment1{3 /* abstract properties */ }X final class AutoValue_Payment1extends2$AutoValue_Payment { /* value type implementation */ }Y abstract class $AutoValue_Payment1extends2Payment { /* extension implementation */ }Y @AutoValue public abstract class Payment1{3 /* abstract properties */ }X

Slide 71

Slide 71 text

Extension API public boolean mustBeFinal(Context context) false true final class AutoValue_Payment1extends2$AutoValue_Payment { /* extension implementation */ }Y abstract class $AutoValue_Payment1extends2Payment { /* value type implementation */ }Y @AutoValue public abstract class Payment1{3 /* abstract properties */ }X final class AutoValue_Payment1extends2$AutoValue_Payment { /* value type implementation */ }Y abstract class $AutoValue_Payment1extends2Payment { /* extension implementation */ }Y @AutoValue public abstract class Payment1{3 /* abstract properties */ }X

Slide 72

Slide 72 text

Extension API public abstract class AutoValueExtension {
 public boolean applicable(Context context) {
 return false;
 }
 
 public boolean mustBeFinal(Context context) {
 return false;
 }
 
 public Set consumeProperties(Context context) {
 return Collections.emptySet();
 }
 
 public abstract String generateClass(Context context, String className, String classToExtend, boolean isFinal);
 }

Slide 73

Slide 73 text

Extension API public abstract class AutoValueExtension {
 public boolean applicable(Context context) {
 return false;
 }
 
 public boolean mustBeFinal(Context context) {
 return false;
 }
 
 public Set consumeProperties(Context context) {
 return Collections.emptySet();
 }
 
 public abstract String generateClass(Context context, String className, String classToExtend, boolean isFinal);
 }

Slide 74

Slide 74 text

Extension API public Set consumeProperties(Context context)

Slide 75

Slide 75 text

Extension API public Set consumeProperties(Context context) @AutoValue public abstract class Payment implements Parcelable { public abstract String note(); }

Slide 76

Slide 76 text

Extension API public Set consumeProperties(Context context) @AutoValue public abstract class Payment implements Parcelable { public abstract String note(); } Extension [ ]

Slide 77

Slide 77 text

Extension API public Set consumeProperties(Context context) @AutoValue public abstract class Payment implements Parcelable { public abstract String note(); } Extension [ ] [ "note", "describeContents" ]

Slide 78

Slide 78 text

Extension API public Set consumeProperties(Context context) @AutoValue public abstract class Payment implements Parcelable { public abstract String note(); } Extension [ ] [ "note", "describeContents" ] @AutoValue public abstract class Payment implements Parcelable { public abstract String note(); } Extension [ "describeContents" ] [ "note" ]

Slide 79

Slide 79 text

Extension API public abstract class AutoValueExtension {
 public boolean applicable(Context context) {
 return false;
 }
 
 public boolean mustBeFinal(Context context) {
 return false;
 }
 
 public Set consumeProperties(Context context) {
 return Collections.emptySet();
 }
 
 public abstract String generateClass(Context context, String className, String classToExtend, boolean isFinal);
 }

Slide 80

Slide 80 text

Extension API public abstract class AutoValueExtension {
 public boolean applicable(Context context) {
 return false;
 }
 
 public boolean mustBeFinal(Context context) {
 return false;
 }
 
 public Set consumeProperties(Context context) {
 return Collections.emptySet();
 }
 
 public abstract String generateClass(Context context, String className, String classToExtend, boolean isFinal);
 }

Slide 81

Slide 81 text

Building Extensions

Slide 82

Slide 82 text

Building Extensions • Model it after the existing extensions

Slide 83

Slide 83 text

Building Extensions • Model it after the existing extensions • Try to play nice with other extensions

Slide 84

Slide 84 text

Building Extensions • Model it after the existing extensions • Try to play nice with other extensions • JavaPoet: github.com/square/javapoet • Truth: github.com/google/truth • compile-testing: github.com/google/compile-testing • auto/service: github.com/google/auto

Slide 85

Slide 85 text

1.2-SNAPSHOT?!?

Slide 86

Slide 86 text

1.2-SNAPSHOT?!? Big Bang

Slide 87

Slide 87 text

1.2-SNAPSHOT?!? Big Bang AutoValue 1.1 released (10 months ago)

Slide 88

Slide 88 text

1.2-SNAPSHOT?!? Big Bang AutoValue 1.1 released (10 months ago) Extensions merged (9 months ago)

Slide 89

Slide 89 text

1.2-SNAPSHOT?!? Big Bang AutoValue 1.1 released (10 months ago) Extensions merged (9 months ago)

Slide 90

Slide 90 text

1.2-SNAPSHOT?!? Big Bang Heat death of universe AutoValue 1.1 released (10 months ago) Extensions merged (9 months ago) AutoValue 1.2 released ??????

Slide 91

Slide 91 text

jakewharton jakewharton jakewharton twitter.com/ google.com/+ .com AutoValue Extensions