将常量与标志组合在一起
使用设置为 true 的 IntDef#flag() 属性,可以组合多个常量。
使用本主题中的相同示例 :
public abstract class Car {
//Define the list of accepted constants
@IntDef(flag=true, value={MICROCAR, CONVERTIBLE, SUPERCAR, MINIVAN, SUV})
//Tell the compiler not to store annotation data in the .class file
@Retention(RetentionPolicy.SOURCE)
.....
}
用户可以将允许的常量与标志(例如|,&,^)组合在一起。