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);
}
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);
}