Skip to content

Commit 6e2ab57

Browse files
committed
Allow passing explicit registration id for SimpleModule via constructor
1 parent e38907e commit 6e2ab57

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

src/main/java/com/fasterxml/jackson/databind/module/SimpleModule.java

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,7 @@ public class SimpleModule
102102
* use actual name and version number information.
103103
*/
104104
public SimpleModule() {
105-
// can't chain when making reference to 'this'
106-
// note: generate different name for direct instantiation, sub-classing
107-
_name = (getClass() == SimpleModule.class) ?
108-
"SimpleModule-"+System.identityHashCode(this)
109-
: getClass().getName();
110-
_version = Version.unknownVersion();
111-
_id = _createId();
105+
this((String) null);
112106
}
113107

114108
/**
@@ -137,11 +131,20 @@ public SimpleModule(Version version) {
137131
* @param version Version of the module
138132
*/
139133
public SimpleModule(String name, Version version) {
134+
this(name, version, null);
135+
}
136+
137+
public SimpleModule(String name, Version version, Object registrationId) {
138+
if (name == null) {
139+
name = (getClass() == SimpleModule.class) ?
140+
"SimpleModule-"+System.identityHashCode(this)
141+
: getClass().getName();
142+
}
140143
_name = name;
141144
_version = version;
142-
_id = _createId();
145+
_id = (registrationId == null) ? _createId() : registrationId;
143146
}
144-
147+
145148
// 27-Feb-2018, tatu: Need to create Registration Id that never matches any
146149
// other id, but is serializable
147150
protected Object _createId() {

0 commit comments

Comments
 (0)