-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Move jackson-datatype-jsr310
into jackson-databind
#5032
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 11 commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
9744808
start of move
pjfanning 0141457
tests
pjfanning b25ee25
move javatimefeature enable to mapperbuilder
pjfanning 615f6f2
accidental edit (fixed)
pjfanning e5b0263
auto-enable JavaTimeModule - breaks a few tests
pjfanning e586ec5
remove code that warns if java.time classes are used but module is no…
pjfanning 70d3194
remove JavaTimeModule
pjfanning d47a0e9
fix test - no longer fails because java.time is now supported out of …
pjfanning c78b6cb
Update POJONodeTest.java
pjfanning 67e4154
make method private - class is final anyway
pjfanning 30b97d8
Update module-info.java
pjfanning 1393821
change package name
pjfanning 27ef8b7
Merge branch 'master' into datetime
cowtowncoder 0dd3dfc
Merge branch 'master' into datetime
cowtowncoder 1be24ec
Merge branch 'master' into datetime
cowtowncoder 27bafa4
Merge branch 'master' into datetime
cowtowncoder e8c7c99
Merge branch 'master' into datetime
cowtowncoder 3d39a7f
Merge branch 'master' into datetime
cowtowncoder f4325b7
Merge https://github.com/FasterXML/jackson-modules-java8/issues/364 c…
cowtowncoder 6f43389
Minor Javadoc improvements
cowtowncoder d6d8d04
Start conversion to make `JavaTimeFeature` be accessed via `DatatypeF…
cowtowncoder 0f8a890
Bit of refactoring wrt JavaTimeFeature
cowtowncoder 6432627
Minor refactoring
cowtowncoder 6e25e80
Refactoring: change "ext.datetime" to "ext.javatime" wrt supported AP…
cowtowncoder 765ca83
Minor javadoc improvements
cowtowncoder c5ffdd8
Rename JavaTimeFeature as DateTimeFeature for use with java.util/Joda…
cowtowncoder 53303b9
Minor reordering
cowtowncoder File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,8 +13,11 @@ | |
|
||
import tools.jackson.core.*; | ||
import tools.jackson.core.util.DefaultPrettyPrinter; | ||
import tools.jackson.core.util.JacksonFeatureSet; | ||
import tools.jackson.core.util.Snapshottable; | ||
import tools.jackson.databind.*; | ||
import tools.jackson.databind.datetime.JavaTimeFeature; | ||
import tools.jackson.databind.datetime.JavaTimeInitializer; | ||
import tools.jackson.databind.deser.*; | ||
import tools.jackson.databind.introspect.*; | ||
import tools.jackson.databind.jsontype.*; | ||
|
@@ -241,6 +244,12 @@ public abstract class MapperBuilder<M extends ObjectMapper, | |
*/ | ||
protected int _formatWriteFeatures; | ||
|
||
/** | ||
* States of {@link JavaTimeFeature}s to enable/disable. | ||
*/ | ||
protected JacksonFeatureSet<JavaTimeFeature> _javaTimeFeatures = | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ahhhh. Ok, here's something we'll need to change: new I can do that tomorrow. |
||
JacksonFeatureSet.fromDefaults(JavaTimeFeature.values()); | ||
|
||
/* | ||
/********************************************************************** | ||
/* Transient state | ||
|
@@ -419,8 +428,9 @@ public MapperBuilderState saveStateApplyModules() | |
{ | ||
if (_savedState == null) { | ||
_savedState = _saveState(); | ||
ModuleContextBase ctxt = _constructModuleContext(); | ||
JavaTimeInitializer.getInstance().setupModule(ctxt); | ||
if (_modules != null) { | ||
ModuleContextBase ctxt = _constructModuleContext(); | ||
_modules.values().forEach(m -> m.setupModule(ctxt)); | ||
// and since context may buffer some changes, ensure those are flushed: | ||
ctxt.applyChanges(this); | ||
|
@@ -493,6 +503,14 @@ public boolean isEnabled(StreamWriteFeature f) { | |
return f.enabledIn(_streamWriteFeatures); | ||
} | ||
|
||
public boolean isEnabled(JavaTimeFeature f) { | ||
return _javaTimeFeatures.isEnabled(f); | ||
} | ||
|
||
public JacksonFeatureSet<JavaTimeFeature> getJavaTimeFeatures() { | ||
return _javaTimeFeatures; | ||
} | ||
|
||
public DatatypeFeatures datatypeFeatures() { | ||
return _datatypeFeatures; | ||
} | ||
|
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
77 changes: 77 additions & 0 deletions
77
src/main/java/tools/jackson/databind/datetime/JavaTimeFeature.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
package tools.jackson.databind.datetime; | ||
|
||
import tools.jackson.core.util.JacksonFeature; | ||
|
||
/** | ||
* Configurable on/off features for Java 8 Date/Time module ({@link JavaTimeInitializer}). | ||
* | ||
* @since 2.16 | ||
*/ | ||
public enum JavaTimeFeature implements JacksonFeature | ||
{ | ||
/** | ||
* Feature that determines whether {@link java.time.ZoneId} is normalized | ||
* (via call to {@code java.time.ZoneId#normalized()}) when deserializing | ||
* types like {@link java.time.ZonedDateTime}. | ||
*<p> | ||
* Default setting is enabled, for backwards-compatibility with | ||
* Jackson 2.15. | ||
*/ | ||
NORMALIZE_DESERIALIZED_ZONE_ID(true), | ||
|
||
/** | ||
* Feature that determines whether the {@link java.util.TimeZone} of the | ||
* {@link tools.jackson.databind.DeserializationContext} is used | ||
* when leniently deserializing {@link java.time.LocalDate} or | ||
* {@link java.time.LocalDateTime} from the UTC/ISO instant format. | ||
* <p> | ||
* Default setting is disabled, for backwards-compatibility with | ||
* Jackson 2.18. | ||
* | ||
* @since 2.19 | ||
*/ | ||
USE_TIME_ZONE_FOR_LENIENT_DATE_PARSING(false), | ||
|
||
/** | ||
* Feature that controls whether stringified numbers (Strings that without | ||
* quotes would be legal JSON Numbers) may be interpreted as | ||
* timestamps (enabled) or not (disabled), in case where there is an | ||
* explicitly defined pattern ({@code DateTimeFormatter}) for value. | ||
* <p> | ||
* Note that when the default pattern is used (no custom pattern defined), | ||
* stringified numbers are always accepted as timestamps regardless of | ||
* this feature. | ||
*/ | ||
ALWAYS_ALLOW_STRINGIFIED_DATE_TIMESTAMPS(false), | ||
|
||
/** | ||
* Feature that determines whether {@link java.time.Month} is serialized | ||
* and deserialized as using a zero-based index (FALSE) or a one-based index (TRUE). | ||
* For example, "1" would be serialized/deserialized as Month.JANUARY if TRUE and Month.FEBRUARY if FALSE. | ||
*<p> | ||
* Default setting is false, meaning that Month is serialized/deserialized as a zero-based index. | ||
*/ | ||
ONE_BASED_MONTHS(false) | ||
; | ||
|
||
/** | ||
* Whether feature is enabled or disabled by default. | ||
*/ | ||
private final boolean _defaultState; | ||
|
||
private final int _mask; | ||
|
||
JavaTimeFeature(boolean enabledByDefault) { | ||
_defaultState = enabledByDefault; | ||
_mask = (1 << ordinal()); | ||
} | ||
|
||
@Override | ||
public boolean enabledByDefault() { return _defaultState; } | ||
|
||
@Override | ||
public boolean enabledIn(int flags) { return (flags & _mask) != 0; } | ||
|
||
@Override | ||
public int getMask() { return _mask; } | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.