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

Add the @Constants annotation for constant holding static inner classes in #111

Closed sbosley closed 9 years ago

sbosley commented 9 years ago

Most constants can safely be copied directly to the generated model. However, constants that are defined using table schema fields (e.g. from Properties, Table, View, like public static final Order DEFAULT_ORDER = Model.COLUMN.asc()) may run into class loading order issues where the fields needed to initialize the constant have not yet themselves been initialized at class loading time. (This is discussed in more detail in #110.

This commit allows constants to be declared in a static inner class of the model spec, effectively deferring initialization of copied constants until after the full schema has been initialized. The old behavior of directly copying constants has been left intact so those who don't need this control over class loading order can use things as they always have.

jdkoren commented 9 years ago

LGTM