Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6529652

(prefs) Preferences should permit get/put on enumerations

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Unresolved
    • Icon: P4 P4
    • None
    • 5.0
    • core-libs

      We have been using Preferences quite a bit recently in NetBeans 6.0, which newly supports it directly for application configuration. I find it common to have some prefs key whose value should be restricted to values of a Java enumeration. Since enumerations could easily be treated as a primitive type (remember even Java language switch statements support this), it would make sense if Preferences let you directly read and write enumeration values, rather than needing to go through a manual conversion. For example, it would be nice to type:

      enum Difficulty {EASY, MEDIUM, HARD}
      private static Preferences p;
      public static void setDifficulty(Difficulty d) {
        p.putEnum("difficulty", d);
      }
      public static Difficulty getDifficulty() {
        return p.getEnum("difficulty", Difficulty.EASY);
      }

            sherman Xueming Shen
            jglick Jesse Glick (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Imported:
              Indexed: