@Test public void testNewLinearId() { AtomicLong id = new AtomicLong(0); assertThat(IdGenerator.newLinearId(id)).isEqualTo(1); assertThat(IdGenerator.newLinearId(id)).isEqualTo(2); id.set(IdGenerator.MAX - 1L); assertThat(IdGenerator.newLinearId(id)).isEqualTo(IdGenerator.MAX); assertThat(IdGenerator.newLinearId(id)).isEqualTo(1L); }
public static long newLinearId(AtomicLong longValue) { long candiateId = longValue.incrementAndGet(); if (candiateId > IdGenerator.MAX) { longValue.set(1L); candiateId = longValue.longValue(); } return candiateId; }
IdGenerator { public static long newLinearId(AtomicLong longValue) { long candiateId = longValue.incrementAndGet(); if (candiateId > IdGenerator.MAX) { longValue.set(1L); candiateId = longValue.longValue(); } return candiateId; } }
IdGenerator { public static long newLinearId(AtomicLong longValue) { long candiateId = longValue.incrementAndGet(); if (candiateId > IdGenerator.MAX) { longValue.set(1L); candiateId = longValue.longValue(); } return candiateId; }  }
IdGenerator { public static long newLinearId(AtomicLong longValue) { long candiateId = longValue.incrementAndGet(); if (candiateId > IdGenerator.MAX) { longValue.set(1L); candiateId = longValue.longValue(); } return candiateId; }  static long newRandomId(@Nullable Set<Long> existingIds); static long newLinearId(AtomicLong longValue); }
IdGenerator { public static long newLinearId(AtomicLong longValue) { long candiateId = longValue.incrementAndGet(); if (candiateId > IdGenerator.MAX) { longValue.set(1L); candiateId = longValue.longValue(); } return candiateId; }  static long newRandomId(@Nullable Set<Long> existingIds); static long newLinearId(AtomicLong longValue); static final long MIN; static final long MAX; }