code: public static final double keepIn(double value, double min, double max) {
          return Math.max(min, Math.min(value, max));
      }
docs: This methods returns the value or min if too small or max if too big.