Skip to content

Instantly share code, notes, and snippets.

@zaki50
Last active August 29, 2015 14:21
Show Gist options
  • Select an option

  • Save zaki50/d09070c76f7532a7df1f to your computer and use it in GitHub Desktop.

Select an option

Save zaki50/d09070c76f7532a7df1f to your computer and use it in GitHub Desktop.
public enum Size {
L(SIZE_L), M(SIZE_M), S(SIZE_S);
@ValidSize
private final int rawValue;
Size(@ValidSize int rawValue) {
this.rawValue = rawValue;
}
@ValidSize
public int getRawValue() {
return rawValue;
}
@Retention(RetentionPolicy.SOURCE)
@IntDef({SIZE_L, SIZE_M, SIZE_S})
public @interface ValidSize {
int SIZE_L = 1;
int SIZE_M = 2;
int SIZE_S = 3;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment