@Test public void testNext() { assertEquals(new Long(1L), wtx(tx -> getSequences().next(tx, "seq1"))); assertEquals(new Long(2L), wtx(tx -> getSequences().next(tx, "seq1"))); assertEquals(new Long(1L), wtx(tx -> getSequences().next(tx, "seq2"))); assertEquals(new Long(2L), wtx(tx -> getSequences().next(tx, "seq2"))); assertEquals(new Long(3L), wtx(tx -> getSequences().next(tx, "seq2"))); }
public long next(Tx.Write tx, String name) { final Key key = Key.of(name); final Optional<Long> seqValue = ixMap.get(tx, key); if (seqValue.isPresent()) { final long nextValue = seqValue.get() + 1; ixMap.put(tx, key, nextValue); return nextValue; } ixMap.put(tx, key, 1L); return 1L; }
SequencesStore extends GenericStoreImpl<Long> { public long next(Tx.Write tx, String name) { final Key key = Key.of(name); final Optional<Long> seqValue = ixMap.get(tx, key); if (seqValue.isPresent()) { final long nextValue = seqValue.get() + 1; ixMap.put(tx, key, nextValue); return nextValue; } ixMap.put(tx, key, 1L); return 1L; } }
SequencesStore extends GenericStoreImpl<Long> { public long next(Tx.Write tx, String name) { final Key key = Key.of(name); final Optional<Long> seqValue = ixMap.get(tx, key); if (seqValue.isPresent()) { final long nextValue = seqValue.get() + 1; ixMap.put(tx, key, nextValue); return nextValue; } ixMap.put(tx, key, 1L); return 1L; } @Autowired  SequencesStore(Storage storage); }
SequencesStore extends GenericStoreImpl<Long> { public long next(Tx.Write tx, String name) { final Key key = Key.of(name); final Optional<Long> seqValue = ixMap.get(tx, key); if (seqValue.isPresent()) { final long nextValue = seqValue.get() + 1; ixMap.put(tx, key, nextValue); return nextValue; } ixMap.put(tx, key, 1L); return 1L; } @Autowired  SequencesStore(Storage storage); long next(Tx.Write tx, String name); }
SequencesStore extends GenericStoreImpl<Long> { public long next(Tx.Write tx, String name) { final Key key = Key.of(name); final Optional<Long> seqValue = ixMap.get(tx, key); if (seqValue.isPresent()) { final long nextValue = seqValue.get() + 1; ixMap.put(tx, key, nextValue); return nextValue; } ixMap.put(tx, key, 1L); return 1L; } @Autowired  SequencesStore(Storage storage); long next(Tx.Write tx, String name);  }