frankiesardo / auto-parcel

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

Support for String arrays #21

Closed littledot closed 9 years ago

littledot commented 9 years ago

I declared a class that has a String array property.

@AutoParcel
public abstract class Foo implements Parcelable {
    abstract String[] bar();
}

However, the compiler throws:

An @AutoParcel class cannot define an array-valued property unless it is a primitive array

Is there any reason to not have support for String arrays?

frankiesardo commented 9 years ago

To ensure immutability of the underlying class and consistency of the hashcode and equality checks, AutoValue rejects any array that is not a primitive type. It is a pessimistic behaviour and Strings are immutable, so it should work with it. However, Java arrays are fundamentally broken and I would discourage their use in any case. But if you feel like that's something they should add you can open an issue upstream: https://github.com/google/auto/issues

littledot commented 9 years ago

Closing because auto-value will not support object arrays.

Object arrays are not and will not be supported, including multidimensional primitive array types. Use a Collection type instead, such as ImmutableList.