Iterate through values in @IntDef, @StringDef or any @Def class
问题 Consider this class: public class MyClassOfMystery { public static final int NO_FLAGS = ~0; public static final int FIRST_FLAG = 1; public static final int SECOND_FLAG = 1 << 1; public static final int THIRD_FLAG = 1 << 2; public static final int FOURTH_FLAG = 1 << 3; @Retention(RetentionPolicy.SOURCE) @IntDef(flag = true, value = {NO_FLAGS, FIRST_FLAG, SECOND_FLAG, THIRD_FLAG, FOURTH_FLAG}) public @interface MysteryFlags { } ... set flags, get flags, and use flags stuff. } I have often