diff --git a/src/main/java/org/orekit/rugged/refraction/ConstantRefractionLayer.java b/src/main/java/org/orekit/rugged/refraction/ConstantRefractionLayer.java index 3b0da0c8169d04a509ee90bff98a7c1144d6938c..b89f4cd3d693e400b6347bd60790af5046244153 100644 --- a/src/main/java/org/orekit/rugged/refraction/ConstantRefractionLayer.java +++ b/src/main/java/org/orekit/rugged/refraction/ConstantRefractionLayer.java @@ -19,8 +19,9 @@ package org.orekit.rugged.refraction; /** * Class that represents a constant refraction layer to be used with {@link MultiLayerModel}. * @author Sergio Esteves + * @since 2.0 */ -public class ConstantRefractionLayer implements Comparable<ConstantRefractionLayer> { +public class ConstantRefractionLayer { /** lowest altitude of this layer. */ private final Double lowestAltitude; @@ -45,30 +46,4 @@ public class ConstantRefractionLayer implements Comparable<ConstantRefractionLay return refractiveIndex; } - @Override - public int compareTo(final ConstantRefractionLayer o) { - return lowestAltitude.compareTo(o.lowestAltitude); - } - - @Override - public boolean equals(final Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - final ConstantRefractionLayer that = (ConstantRefractionLayer) o; - - if (Double.compare(that.refractiveIndex, refractiveIndex) != 0) return false; - return lowestAltitude != null ? lowestAltitude.equals(that.lowestAltitude) : that.lowestAltitude == null; - - } - - @Override - public int hashCode() { - int result; - long temp; - result = lowestAltitude != null ? lowestAltitude.hashCode() : 0; - temp = Double.doubleToLongBits(refractiveIndex); - result = 31 * result + (int) (temp ^ (temp >>> 32)); - return result; - } } diff --git a/src/main/java/org/orekit/rugged/refraction/MultiLayerModel.java b/src/main/java/org/orekit/rugged/refraction/MultiLayerModel.java index 2d9065f94f15e09741e842a49d193a38413a11eb..87e9df4c73090b72bf8a241811149375e0396f51 100644 --- a/src/main/java/org/orekit/rugged/refraction/MultiLayerModel.java +++ b/src/main/java/org/orekit/rugged/refraction/MultiLayerModel.java @@ -33,6 +33,7 @@ import java.util.List; /** * Multi layer model for atmospheric refraction. * @author Sergio Esteves, Luc Maisonobe + * @since 2.0 */ public class MultiLayerModel implements AtmosphericRefraction { @@ -73,13 +74,14 @@ public class MultiLayerModel implements AtmosphericRefraction { /** Simple constructor. * @param ellipsoid the ellipsoid to be used. - * @param refractionLayers the refraction layers to be used with this model. + * @param refractionLayers the refraction layers to be used with this model (layers can be in any order). */ public MultiLayerModel(final ExtendedEllipsoid ellipsoid, final List<ConstantRefractionLayer> refractionLayers) { this.ellipsoid = ellipsoid; - this.refractionLayers = refractionLayers; - Collections.sort(this.refractionLayers, Collections.<ConstantRefractionLayer>reverseOrder()); - atmosphereLowestAltitude = refractionLayers.get(refractionLayers.size() - 1).getLowestAltitude(); + this.refractionLayers = new ArrayList<>(refractionLayers); + Collections.sort(this.refractionLayers, + (l1, l2) -> Double.compare(l2.getLowestAltitude(), l1.getLowestAltitude())); + atmosphereLowestAltitude = this.refractionLayers.get(this.refractionLayers.size() - 1).getLowestAltitude(); } /** {@inheritDoc} */