code: public static int clamp(int value, int min, int max) {
  		return Math.min(Math.max(min, value), max);
  	}
docs: Get the value if it is between min and max, min if the value is less than min, or max if the
  value is greater than max.