frankiesardo / auto-parcel

Android Parcelable models made easy
Eclipse Public License 1.0
1.37k stars 83 forks source link

Why do we need to call all Builder methods? #37

Closed bobroalexandr closed 8 years ago

bobroalexandr commented 8 years ago

new IllegalStateException("Missing required properties:" + missing is thrown if I don't call all Builder methods. Why do you have such behavior there? Sometimes developer may need to call : AutoParcel_SomeObject.Builder().build(); and now IllegalStateException will be thrown in this case.

Seems like @Nullable annotation solves that problem but that a bad practice to use that annotation near primitive types.

PaulWoitaschek commented 8 years ago

Because there is no default value declared.

All backing fields you declare are NonNull by default. So you have to declare all fields.

If you really want null you can declare all fields nullable, like you wrote.

Or to have some pre initialization you can add a static factory method to prepare the builder with all values you like.

bobroalexandr commented 8 years ago

And why don't use Java default values for primitive types? How can I set default values for primitives?

frankiesardo commented 8 years ago

AutoParcel now uses the AutoValue extension apis. Please refer to https://github.com/google/auto/tree/master/value for implementation and potential issues