Package de.xima.fc.user_portal.common
Class ComparableUtils
- java.lang.Object
-
- de.xima.fc.user_portal.common.ComparableUtils
-
public final class ComparableUtils extends Object
Utility class for comparing comparable values.- Since:
- 8.2.0
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T extends Comparable<T>>
TconstrainToRange(T value, T min, T max)
Constrains a comparable value to a range.static <T extends Comparable<T>>
TconstrainToRange(T value, T min, T max, T defaultValue)
Constrains a comparable value to a range.
-
-
-
Method Detail
-
constrainToRange
public static <T extends Comparable<T>> T constrainToRange(T value, T min, T max)
Constrains a comparable value to a range.- Type Parameters:
T
- Type of the value.- Parameters:
value
- Value to constrain.min
- Minimum value.max
- Maximum value.- Returns:
- The value if it is within the range, the minimum value if it is below the range, the maximum value if it is above the range.
-
constrainToRange
public static <T extends Comparable<T>> T constrainToRange(T value, T min, T max, T defaultValue)
Constrains a comparable value to a range.- Type Parameters:
T
- Type of the value.- Parameters:
value
- Value to constrain.min
- Minimum value.max
- Maximum value.defaultValue
- Default value if the value is null.- Returns:
- The value if it is within the range, the minimum value if it is below the range, the maximum value if it is above the range, and the default value if the value is null.
-
-