host.anzo.commons.utils.MathUtils Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of commons-core Show documentation
Show all versions of commons-core Show documentation
Commons library to make me happy.
package host.anzo.commons.utils;
import org.jetbrains.annotations.NotNull;
/**
* @author ANZO
* @since 9/11/2024
*/
public class MathUtils {
public static > T clamp(@NotNull T value, T min, T max) {
if (value.compareTo(min) < 0) {
return min;
} else if (value.compareTo(max) > 0) {
return max;
} else {
return value;
}
}
}