private int adaptToStepSize(final int number) {
        if (getStepSize() > 0) {
            int offset = number - getMinNumber();
            int mod = offset % getStepSize();
            float halfStepSize = (float) getStepSize() / 2.0f;
            int result = ((mod > halfStepSize) ? offset + getStepSize() - mod : offset - mod) +
                    getMinNumber();
            return Math.min(result, getMaxNumber());
        }

        return number;
    }
private int adaptToStepSize ( final int number ) { if ( getStepSize ( ) > 0 ) { int offset = number - getMinNumber ( ) ; int mod = offset % getStepSize ( ) ; float halfStepSize = ( float ) getStepSize ( ) / 2.0f ; int result = ( ( mod > halfStepSize ) ? offset + getStepSize ( ) - mod : offset - mod ) + getMinNumber ( ) ; return Math . min ( result , getMaxNumber ( ) ) ; } return number ; }
Adapts a specific number to the step size, which is currently set. The number will be
decreased or increased to the numerically closest value, which matches the step size.

@param number
The number, which should be adapted to the step size, as an {@link Integer} value
@return The adapted number as an {@link Integer} value