@Test public void testDecrement() { int testSize = 100000; UUID current = UUIDUtils.MAX_TIME_UUID; UUID previous = current; for ( int i = 0; i < testSize; i++ ) { current = UUIDUtils.decrement( current ); assertEquals( -1, current.compareTo( previous ) ); if ( i % 1000 == 0 ) { logger.info("testDecrement processed " + i); } previous = current; } }
public static UUID decrement( UUID uuid ) { if ( !isTimeBased( uuid ) ) { throw new IllegalArgumentException( "The uuid must be a time type" ); } long timestamp = uuid.timestamp(); timestamp--; if ( timestamp < 0 ) { throw new IllegalArgumentException( "You must specify a time uuid with a timestamp > 0" ); } byte[] uuidBytes = bytes( uuid ); setTime( uuidBytes, timestamp ); return uuid( uuidBytes ); }
UUIDUtils { public static UUID decrement( UUID uuid ) { if ( !isTimeBased( uuid ) ) { throw new IllegalArgumentException( "The uuid must be a time type" ); } long timestamp = uuid.timestamp(); timestamp--; if ( timestamp < 0 ) { throw new IllegalArgumentException( "You must specify a time uuid with a timestamp > 0" ); } byte[] uuidBytes = bytes( uuid ); setTime( uuidBytes, timestamp ); return uuid( uuidBytes ); } }
UUIDUtils { public static UUID decrement( UUID uuid ) { if ( !isTimeBased( uuid ) ) { throw new IllegalArgumentException( "The uuid must be a time type" ); } long timestamp = uuid.timestamp(); timestamp--; if ( timestamp < 0 ) { throw new IllegalArgumentException( "You must specify a time uuid with a timestamp > 0" ); } byte[] uuidBytes = bytes( uuid ); setTime( uuidBytes, timestamp ); return uuid( uuidBytes ); }  }
UUIDUtils { public static UUID decrement( UUID uuid ) { if ( !isTimeBased( uuid ) ) { throw new IllegalArgumentException( "The uuid must be a time type" ); } long timestamp = uuid.timestamp(); timestamp--; if ( timestamp < 0 ) { throw new IllegalArgumentException( "You must specify a time uuid with a timestamp > 0" ); } byte[] uuidBytes = bytes( uuid ); setTime( uuidBytes, timestamp ); return uuid( uuidBytes ); }  static java.util.UUID newTimeUUID(); static UUID newTimeUUID( long ts, int timeoffset ); static UUID newTimeUUID( long ts ); static UUID maxTimeUUID( long ts ); static UUID min( UUID first, UUID second ); static UUID max( UUID first, UUID second ); static UUID decrement( UUID uuid ); static boolean isTimeBased( UUID uuid ); static long getTimestampInMillis( UUID uuid ); static long getTimestampInMicros( UUID uuid ); static UUID tryGetUUID( String s ); static boolean isUUID( String s ); static UUID tryExtractUUID( String s ); static UUID tryExtractUUID( String s, int offset ); static String toBase64( UUID id ); static UUID fromBase64( String str ); static int compare( UUID u1, UUID u2 ); static List<UUID> sort( List<UUID> uuids ); }
UUIDUtils { public static UUID decrement( UUID uuid ) { if ( !isTimeBased( uuid ) ) { throw new IllegalArgumentException( "The uuid must be a time type" ); } long timestamp = uuid.timestamp(); timestamp--; if ( timestamp < 0 ) { throw new IllegalArgumentException( "You must specify a time uuid with a timestamp > 0" ); } byte[] uuidBytes = bytes( uuid ); setTime( uuidBytes, timestamp ); return uuid( uuidBytes ); }  static java.util.UUID newTimeUUID(); static UUID newTimeUUID( long ts, int timeoffset ); static UUID newTimeUUID( long ts ); static UUID maxTimeUUID( long ts ); static UUID min( UUID first, UUID second ); static UUID max( UUID first, UUID second ); static UUID decrement( UUID uuid ); static boolean isTimeBased( UUID uuid ); static long getTimestampInMillis( UUID uuid ); static long getTimestampInMicros( UUID uuid ); static UUID tryGetUUID( String s ); static boolean isUUID( String s ); static UUID tryExtractUUID( String s ); static UUID tryExtractUUID( String s, int offset ); static String toBase64( UUID id ); static UUID fromBase64( String str ); static int compare( UUID u1, UUID u2 ); static List<UUID> sort( List<UUID> uuids ); static final UUID MIN_TIME_UUID; static final UUID MAX_TIME_UUID; static final UUID ZERO_UUID; }