Class MutableNumberRange
java.lang.Object
etithespirit.orimod.api.util.valuetypes.NumberRange
etithespirit.orimod.api.util.valuetypes.MutableNumberRange
An implementation of
NumberRange
that can have its minimum and maximum set after construction.- Author:
- Eti
-
Field Summary
Fields inherited from class etithespirit.orimod.api.util.valuetypes.NumberRange
max, min, rng, ZERO
-
Constructor Summary
ConstructorsConstructorDescriptionMutableNumberRange
(double min, double max) Creates a new range between min and max.MutableNumberRange
(double min, double max, Random rng) Creates a new range between min and max, using the given randomizer for theNumberRange.random()
method. -
Method Summary
Modifier and TypeMethodDescriptionboolean
void
setMax
(double max) Sets the value of max.void
setMin
(double min) Sets the value of min.void
setMinAndMax
(double min, double max) A method to set both the value of min and the value of max simultaneously.Methods inherited from class etithespirit.orimod.api.util.valuetypes.NumberRange
equals, getMax, getMin, isSingular, lerp, random
-
Constructor Details
-
MutableNumberRange
Creates a new range between min and max. If min is greater than max, anIllegalArgumentException
is thrown.- Parameters:
min
- The minimum possible value to contain.max
- The maximum possible value to contain.- Throws:
IllegalArgumentException
- If min is greater than max.
-
MutableNumberRange
Creates a new range between min and max, using the given randomizer for theNumberRange.random()
method. If min is greater than max, anIllegalArgumentException
is thrown.- Parameters:
min
- The minimum possible value to contain.max
- The maximum possible value to contain.rng
- The randomizer to use in theNumberRange.random()
method.- Throws:
IllegalArgumentException
- If min is greater than max.
-
-
Method Details
-
setMin
Sets the value of min.- Parameters:
min
- The new value of min.- Throws:
IllegalArgumentException
- If the new value is greater than the current maximum.
-
setMax
Sets the value of max.- Parameters:
max
- The new value of max.- Throws:
IllegalArgumentException
- If the new value is less than the current minimum.
-
setMinAndMax
A method to set both the value of min and the value of max simultaneously.- Parameters:
min
- The new value of min.max
- The new value of max.- Throws:
IllegalArgumentException
- If min is greater than max.
-
isMutable
public boolean isMutable()- Overrides:
isMutable
in classNumberRange
- Returns:
- Whether or not this
NumberRange
is able to have its minimum and maximum edited.
-
immutableCopy
- Overrides:
immutableCopy
in classNumberRange
- Returns:
- A copy of this
NumberRange
as an immutable instance.
-
mutableCopy
- Overrides:
mutableCopy
in classNumberRange
- Returns:
- A copy of this
NumberRange
as a mutable instance.
-