yahoo / squidb

SquiDB is a SQLite database library for Android and iOS
https://github.com/yahoo/squidb/wiki
Apache License 2.0
1.31k stars 132 forks source link

Property lists [4.0] #269

Closed sbosley closed 7 years ago

sbosley commented 7 years ago

The main focus of this PR is to make the PROPERTIES array in every model class be declared as an immutable list rather than an array. Immutable lists for model properties are safer than arrays because the user can't modify their contents accidentally (they'd have to work very hard to do so). This also reduces the need to pass an array to a varargs method, for which Android Studio logs an ambiguity warning if no explicit cast is present.

Several related APIs have been changed slightly in light of this. Most methods that accepted a varargs property list now have a variant that accepts List<? extends Property<?>> as well. Some APIs that consume List<Field<?>> or List<Property<?>> arguments are now more flexible and accept List<? extends Field<?>> or List<? extends Property<?>>. A (minor) typesafety issue related to bad handling of Function objects in the SqlTable qualifyField and related methods has also been fixed -- these methods now make a clear distinction between qualifyField, which returns a Field<?>, and qualifyProperty, which can infer its return type from its argument type.

Finally, methods and constructors that accepted Map<String, Object> have been removed in favor of variants that only accept ValuesStorage, which is more typesafe.