Interface ClampedInt

All Superinterfaces:
Comparable<ValueProvider>, IntProvider, ValueProvider, Wrapper

@NullMarked @AsOf("3.0.0") public interface ClampedInt extends IntProvider
Samples a source() provider and hard-clamps the result into [IntProvider.minInclusive(), IntProvider.maxInclusive()]. Because it clamps rather than rerolls, probability mass outside the bounds piles up on the bounds, so a clamped uniform is not uniform: the endpoints become disproportionately likely.
Since:
3.0.0
See Also:
  • Method Details

    • source

      @AsOf("3.0.0") IntProvider source()
      The source provider whose sampled value is clamped.
      Returns:
      the source provider
      Since:
      3.0.0
    • toBuilder

      @AsOf("3.0.0") default ClampedInt.Builder toBuilder()
      Converts this object back to a builder.
      Returns:
      a builder with the same values as this object
      Since:
      3.0.0
    • of

      @AsOf("3.0.0") static ClampedInt of(IntProvider source, int min, int max)
      Creates a new clamped int provider.
      Parameters:
      source - the source provider to clamp
      min - the minimum allowed value
      max - the maximum allowed value
      Returns:
      the clamped int provider
      Since:
      3.0.0
    • builder

      @AsOf("3.0.0") static ClampedInt.Builder builder()
      Creates a new builder.
      Returns:
      a new builder
      Since:
      3.0.0