Created
November 3, 2016 02:37
-
-
Save uziassantosferreira/3aa749bb4d096e3d9e8fb0627ef1b42b to your computer and use it in GitHub Desktop.
Example create enum in android annotation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //Example | |
| User user = new User(); | |
| user.age = Numbers.ONE; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @IntDef({Numbers.ONE, Numbers.TWO, Numbers.THREE, Numbers.FOUR}) | |
| @Retention(RetentionPolicy.SOURCE) | |
| @interface Numbers { | |
| int ONE = 1; | |
| int TWO = 2; | |
| int THREE = 3; | |
| int FOUR = 4; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| enum NumbersWithoutAnnotation { | |
| ONE, TWO, THREE, FOUR; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class User { | |
| @Numbers | |
| int age; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment