[jackson-annotations] 21/207: One more fix for ObjectIdGenerator
Timo Aaltonen
tjaalton at moszumanska.debian.org
Sat Sep 6 13:55:35 UTC 2014
This is an automated email from the git hooks/post-receive script.
tjaalton pushed a commit to branch master
in repository jackson-annotations.
commit d15ca50dd6a0a7e8b7a01e7328494b7aa57935a6
Author: Tatu <tatu at ning.com>
Date: Tue Feb 7 19:46:43 2012 -0800
One more fix for ObjectIdGenerator
---
.../jackson/annotation/ObjectIdGenerators.java | 22 ++++++++++++++++------
1 file changed, 16 insertions(+), 6 deletions(-)
diff --git a/src/main/java/com/fasterxml/jackson/annotation/ObjectIdGenerators.java b/src/main/java/com/fasterxml/jackson/annotation/ObjectIdGenerators.java
index 9cceb3d..9615911 100644
--- a/src/main/java/com/fasterxml/jackson/annotation/ObjectIdGenerators.java
+++ b/src/main/java/com/fasterxml/jackson/annotation/ObjectIdGenerators.java
@@ -51,6 +51,16 @@ public class ObjectIdGenerators
return _ids.get(item);
}
+
+ @Override
+ public T generateId(Object forPojo) {
+ T id = _generateId(forPojo);
+ addId(forPojo, id);
+ return id;
+ }
+
+ protected abstract T _generateId(Object forPojo);
+
@Override
public Object findItem(T id) {
if (_items == null) {
@@ -131,7 +141,7 @@ public class ObjectIdGenerators
}
@Override
- public Integer generateId(Object forPojo) {
+ public Integer _generateId(Object forPojo) {
int id = _nextValue;
++_nextValue;
return id;
@@ -165,6 +175,11 @@ public class ObjectIdGenerators
return new UUIDGenerator(_scope);
}
+ @Override
+ protected UUID _generateId(Object forPojo) {
+ return UUID.randomUUID();
+ }
+
/**
* Since UUIDs are always unique, let's fully ignore scope definition
*/
@@ -172,10 +187,5 @@ public class ObjectIdGenerators
public boolean canUseFor(ObjectIdGenerator<?> gen) {
return (gen.getClass() == getClass());
}
-
- @Override
- public UUID generateId(Object forPojo) {
- return UUID.randomUUID();
- }
}
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-java/jackson-annotations.git
More information about the pkg-java-commits
mailing list