Android Typedef Annotations: @IntDef, @StringDef Combining constants with flags

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Example

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})

    //Tell the compiler not to store annotation data in the .class file
    @Retention(RetentionPolicy.SOURCE)

    .....

}

Users can combine the allowed constants with a flag (such as |, &, ^ ).



Got any Android Question?