I have one ENUM and I am updating those enum value from database on initialization of application. And then using that enum all-over application.
The reason to do so is that if Value need to change from database then just add that value in property table and update it, so that on initialization enum values got updated else enum default value will be working.
Example : I have this enum :
public enum Planet {
MERCURY (3.303e+23, 2.4397e6),
VENUS (4.869e+24, 6.0518e6),
EARTH (5.976e+24, 6.37814e6);
private final double mass; // in kilograms
private final double radius; // in meters
Planet(double mass, double radius) {
this.mass = mass;
this.radius = radius;
}
private double mass() { return mass; }
private double radius() { return radius; }
private void setMass(double mass) { this.mass = mass; }
private void setRadius(double radius) { this.radius = radius; }
}
And I update values of Enum with set methods.
I would like to know whether doing this is correct or not. What is the right way to do for such scenarios?