/** * Create a new generator that uses the specified number of bits for the counter portion of the keys. * * @param bitsUsedInCounter the number of bits in the counter portion of the keys; must be a positive number for which theere * is enough space to left shift without overflowing. * @return the generator instance; never null */ public static TimeBasedKeys create( int bitsUsedInCounter ) { CheckArg.isPositive(bitsUsedInCounter, "bitsUsedInCounter"); int maxAvailableBitsToShift = Long.numberOfLeadingZeros(System.currentTimeMillis()); CheckArg.isLessThan(bitsUsedInCounter, maxAvailableBitsToShift, "bitsUsedInCounter"); return new TimeBasedKeys((short)bitsUsedInCounter); }
/** * Create a new generator that uses the specified number of bits for the counter portion of the keys. * * @param bitsUsedInCounter the number of bits in the counter portion of the keys; must be a positive number for which theere * is enough space to left shift without overflowing. * @return the generator instance; never null */ public static TimeBasedKeys create( int bitsUsedInCounter ) { CheckArg.isPositive(bitsUsedInCounter, "bitsUsedInCounter"); int maxAvailableBitsToShift = Long.numberOfLeadingZeros(System.currentTimeMillis()); CheckArg.isLessThan(bitsUsedInCounter, maxAvailableBitsToShift, "bitsUsedInCounter"); return new TimeBasedKeys((short)bitsUsedInCounter); }
/** * Create a new generator that uses the specified number of bits for the counter portion of the keys. * * @param bitsUsedInCounter the number of bits in the counter portion of the keys; must be a positive number for which theere * is enough space to left shift without overflowing. * @return the generator instance; never null */ public static TimeBasedKeys create( int bitsUsedInCounter ) { CheckArg.isPositive(bitsUsedInCounter, "bitsUsedInCounter"); int maxAvailableBitsToShift = Long.numberOfLeadingZeros(System.currentTimeMillis()); CheckArg.isLessThan(bitsUsedInCounter, maxAvailableBitsToShift, "bitsUsedInCounter"); return new TimeBasedKeys((short)bitsUsedInCounter); }
@Test( expected = IllegalArgumentException.class ) public void isLessThanShouldThrowExceptionIfValueIsGreaterThanSuppliedValue() { CheckArg.isLessThan(1, 0, "value"); }
@Test( expected = IllegalArgumentException.class ) public void isLessThanShouldThrowExceptionIfValueIsEqualToSuppliedValue() { CheckArg.isLessThan(1, 1, "value"); }