Skip to content

Instantly share code, notes, and snippets.

@nasrabadiAM
Last active February 12, 2018 08:54
Show Gist options
  • Save nasrabadiAM/ada00068099b14e84582a2071ead5cf7 to your computer and use it in GitHub Desktop.
Save nasrabadiAM/ada00068099b14e84582a2071ead5cf7 to your computer and use it in GitHub Desktop.

replace enums with StringDef

Enum Sample:

   public enum WeekDays {
        SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY
    }

String Def Sample:

  public static final int SUNDAY = 0;
    public static final int MONDAY = 1;
    public static final int TUESDAY = 2;
    public static final int WEDNESDAY = 3;
    public static final int THURSDAY = 4;
    public static final int FRIDAY = 5;
    public static final int SATURDAY = 6;

    @IntDef({SUNDAY, MONDAY,TUESDAY,WEDNESDAY,THURSDAY,FRIDAY,SATURDAY})
    @Retention(RetentionPolicy.SOURCE)
    public @interface WeekDays {}

    @WeekDays int currentDay = SUNDAY;
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment