Combining constants with flags

suggest change

Using the IntDef#flag() attribute set to true, multiple constants can be combined.

Using the same example in this topic:

public abstract class Car {

    // Define the list of accepted constants.
    @IntDef(flag = true, value = {MICROCAR, CONVERTIBLE, SUPERCAR, MINIVAN, SUV})
    // Do not store annotation data in the .class file.
    @Retention(RetentionPolicy.SOURCE)
    public @interface Models {}

}

Callers combine the allowed constants with bitwise operators (|, &, ^). flag = true is what tells Lint those combinations are valid.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents