Skip to content

Commit

Permalink
refactor(math/curves/limited): validate that minimum is not greater t…
Browse files Browse the repository at this point in the history
…han maximum
  • Loading branch information
Baconing committed Sep 30, 2024
1 parent 16883ce commit 046996f
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,11 @@ public class LimitedCurve extends Curve {
* @param curve The curve to limit.
* @param min The minimum value of the curve.
* @param max The maximum value of the curve.
* @throws IllegalArgumentException If the minimum value is greater than the maximum value.
*/
public LimitedCurve(@NotNull Curve curve, double min, double max) {
if (min > max) throw new IllegalArgumentException("Minimum value cannot be greater than maximum value.");

this.curve = curve;
this.min = min;
this.max = max;
Expand Down Expand Up @@ -67,8 +70,10 @@ public double getMin() {
/**
* Sets the minimum value of the curve.
* @param min The new minimum value of the curve.
* @throws IllegalArgumentException If the minimum value is greater than the maximum value.
*/
public void setMin(double min) {
if (min > max) throw new IllegalArgumentException("Minimum value cannot be greater than maximum value.");
this.min = min;
}

Expand All @@ -83,8 +88,10 @@ public double getMax() {
/**
* Sets the maximum value of the curve.
* @param max The new maximum value of the curve.
* @throws IllegalArgumentException If the minimum value is greater than the maximum value.
*/
public void setMax(double max) {
if (min > max) throw new IllegalArgumentException("Minimum value cannot be greater than maximum value.");
this.max = max;
}
}

0 comments on commit 046996f

Please sign in to comment.