Skip to content

Instantly share code, notes, and snippets.

@crowjdh
Last active August 29, 2015 14:14
Show Gist options
  • Save crowjdh/f5443fd7e29ee6accfd2 to your computer and use it in GitHub Desktop.
Save crowjdh/f5443fd7e29ee6accfd2 to your computer and use it in GitHub Desktop.
Restrict integer parameter and return value.
private int mProperty;
@IntDef(value = { PROPERTY_A, PROPERTY_B })
@Retention(RetentionPolicy.SOURCE)
public @interface MyProperty {}
public void setProperty(@MyProperty int property) {
mProperty = Property;
}
public @MyProperty int getProperty() {
return mProperty;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment