I have the following code, based on the input to the constructor I need to initialise some values which are wrapped in a simple POJO.. These values are constant as you can see.
However I don't like the if/else construct and had read about NavigableMap as an alternative for holding range values.. Any thoughts on how to improve/clean the below or indeed use this construct?
Thanks
private Calibrated calibratedValues;
public CalibrationProperties(long odNumber) {
setCalibratedValues(odNumber);
}
private void setCalibratedValues(long odNumber) {
if (odNumber < 762) {
this.calibratedValues = new Calibrated(K0, H0, K0_INV, H0_INV, F0);
} else if (odNumber < 866) {
this.calibratedValues = new Calibrated(K1, H1, K0_INV, H0_INV, F1);
} else if (odNumber < 1011) {
this.calibratedValues = new Calibrated(K2, H2, K2_INV, H2_INV, F2);
} else {
this.calibratedValues = new Calibrated(K3, H3, K3_INV, H3_INV, F3);
}
//Two exceptions
if (odNumber == 858){
this.calibratedValues = new Calibrated(K2, H2, K2_INV, H2_INV, F2);
}
if (odNumber == 1005){
this.calibratedValues = new Calibrated(K3, H3, K3_INV, H3_INV, F3);
}
}
public Calibrated getCalibratedValues() {
return calibratedValues;
}
/** Convenience class used to hold calibrated values */
static class Calibrated {
private double[] k;
private double[] h;
private double[] kinv;
private double[] hinv;
private double f;
Calibrated(double[] k, double[] h, double[] kinv, double[] hinv, double f) {
this.k = k;
this.h = h;
this.kinv = kinv;
this.hinv = hinv;
this.f = f;
}
public double[] getK() {
return k;
}
public double[] getH() {
return h;
}
...