Last active
November 10, 2017 07:57
-
-
Save wreulicke/59aaf6a0bd7aed559d25b5ce5b9d0943 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface Versioned { | |
long getVersion(); | |
void verifyVersion(Long version) default { | |
if (version == null) return; | |
if(getVersion() != version) throw new OptimisticLockFailureException("Unable to lock"); | |
} | |
void setVersion(long version); | |
long incrementVersion() default { | |
long next = getVersion() + 1; | |
setVersion(next); | |
return next; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment