@Test public void generateWithOrder() throws Exception { DummyFlakeGenerator production = new DummyFlakeGenerator(); List<FlakeId> flakeIds = IntStream.range(0, 10240) .mapToObj(i -> production.next()) .collect(Collectors.toList()); assertEquals(10240, flakeIds.size()); ArrayList<FlakeId> oldOrders = new ArrayList<>(flakeIds); Collections.shuffle(flakeIds); Collections.sort(flakeIds); assertEquals(oldOrders, flakeIds); }
public final FlakeId next() { return new FlakeId(getCurrentSequenceTime(), nodeId); }
FlakeIdGenerator { public final FlakeId next() { return new FlakeId(getCurrentSequenceTime(), nodeId); } }
FlakeIdGenerator { public final FlakeId next() { return new FlakeId(getCurrentSequenceTime(), nodeId); } protected  FlakeIdGenerator(int nodeId); @VisibleForTesting  FlakeIdGenerator(int nodeId, Clock clock, String scope); }
FlakeIdGenerator { public final FlakeId next() { return new FlakeId(getCurrentSequenceTime(), nodeId); } protected  FlakeIdGenerator(int nodeId); @VisibleForTesting  FlakeIdGenerator(int nodeId, Clock clock, String scope); final FlakeId next(); final int getNodeId(); }
FlakeIdGenerator { public final FlakeId next() { return new FlakeId(getCurrentSequenceTime(), nodeId); } protected  FlakeIdGenerator(int nodeId); @VisibleForTesting  FlakeIdGenerator(int nodeId, Clock clock, String scope); final FlakeId next(); final int getNodeId();  }