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.
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.
- relates to
-
JDK-6529790 Please add LINE_SEPARATOR constant into System or some other class
- Closed
-
JDK-6547117 System.getProperty is the only way to get some info, but it may throw exception
- Closed