A DESCRIPTION OF THE REQUEST :
Could get an enum for the standard System property keys?
JUSTIFICATION :
This would reduce programming errors.
It is also quite cumbersome to write test cases that actually cover the possibility that the desired property name key has been misspelled in the code.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
public final class System {
public static String getProperty(final Property property) {
return getProperty(property.getPropertyKey());
}
public enum Property {
LINE_SEPARATOR() {
public String getPropertyKey() {
return "line.separator";
}
};
/** Returns the key's String value. */
public abstract String getPropertyKey();
/** Get the system property -- delegates to System.getProperty. */
public String getPropertyValue() {
return getProperty(this);
}
}
}
ACTUAL -
Problematic String literal property keys.
---------- BEGIN SOURCE ----------
...
if (myVariable.equals(System.getProperty("1ine.separator")))
...
else ...
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Define your own such enum.