Class Limits

java.lang.Object
ch.hevs.kart.utils.Limits

public class Limits extends Object

Offers static methods in order to limit values to a given range.

  • Constructor Details

    • Limits

      public Limits()
  • Method Details

    • limit

      public static <T extends Comparable<T>> T limit(T value, T min, T max)

      Generic limit function. Limits the given value to the given range (min, max).

      Type Parameters:
      T - The type of the value and limits have to implement the Comparable interface.
      Parameters:
      value - The input value to limit.
      min - The minimal value.
      max - The maximal allowed value.
      Returns:
      Value limited to the given limits (min, max).