Last active
November 12, 2017 13:55
-
-
Save emedinaa/701203a9f768d980c772934bf396f8c6 to your computer and use it in GitHub Desktop.
Android-Annotations
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
Reference : https://developer.android.com/studio/write/annotations.html#enum-annotations | |
public class FilterColorDescriptor { | |
public static final String FILTER_BLUE = "blue"; | |
public static final String FILTER_RED = "red"; | |
public static final String FILTER_GRAY = "gray"; | |
public final String filterColor; | |
public FilterColorDescriptor(String filterColor) { | |
this.filterColor = filterColor; | |
} | |
} | |
public class FilterColorDescriptor { | |
// ... type definitions | |
// Describes when the annotation will be discarded | |
@Retention(RetentionPolicy.SOURCE) | |
// Enumerate valid values for this interface | |
@StringDef({ FILTER_BLUE, FILTER_RED, FILTER_GRAY }) | |
// Create an interface for validating String types | |
public @interface FilterColorDef { } | |
// Mark the argument as restricted to these enumerated types | |
public FilterColorDescriptor(@FilterColorDef String filterColor) { | |
this.filterColor = filterColor; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment