Package org.spongepowered.api.util
Interface Range<T extends Number>
- Type Parameters:
T
- The type of bound
public interface Range<T extends Number>
Represents a range. The type is unbounded such that optional minima and
maxima can be used.
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic interface
Generates specific implementations of theRange
interface. -
Method Summary
Modifier and TypeMethodDescriptiondoubleRange
(@Nullable Double min, @Nullable Double max) Builds aRange
based on doubles.floatRange
(@Nullable Float min, @Nullable Float max) Builds aRange
based on floats.Builds aRange
based on integers.@Nullable T
max()
Gets the maximum, if it exists.@Nullable T
min()
Gets the minimum, if it exists.
-
Method Details
-
floatRange
Builds aRange
based on floats.- Parameters:
min
- The minimum, ornull
for no minimummax
- The maximum, ornull
for no maximum- Returns:
- The range.
-
intRange
Builds aRange
based on integers.- Parameters:
min
- The minimum, ornull
for no minimummax
- The maximum, ornull
for no maximum- Returns:
- The range.
- Throws:
IllegalArgumentException
- if min is smaller than max
-
doubleRange
Builds aRange
based on doubles.- Parameters:
min
- The minimum, ornull
for no minimummax
- The maximum, ornull
for no maximum- Returns:
- The range.
-
min
@Nullable T min()Gets the minimum, if it exists.- Returns:
- The minimum.
-
max
@Nullable T max()Gets the maximum, if it exists.- Returns:
- The maximum
-