I'm using an AutoValue extension to generate my Parcelable Android classes. The documentation specifically states that one @AutoValue cannot extend another: https://github.com/google/auto/blob/master/value/userguide/howto.md#inherit
Another developer was helping me out with this, and suggested "If you have common fields, you can put them in an interface that both implementations implement." I'm assuming this means the library favors composition over inheritance.
I admit, I'm kind of lost. If someone could provide a simple concrete example of the simplest way to "subclass" an AutoValue class, it would be appreciated. Here's a simple class:
@AutoParcelGson
public abstract class User implements Parcelable {
public abstract String username();
public static User create(String username) {
return builder().username(username).build();
}
public static Builder builder() {
return new AutoParcelGson_User.Builder();
}
@AutoParcelGson.Builder
public interface Builder {
Builder username(String username);
User build();
}
}
I'd like to have another @AutoValue class called Customer that has a few extra fields. Also, @AutoParcelGson is the @AutoValue extension that I am using, but it is the same behavior.