Skip to content

Commit

Permalink
Bit of cleanup in preparation of work for ObjectMapper "buildification"
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Jan 29, 2018
1 parent 73e0067 commit f3ba50c
Show file tree
Hide file tree
Showing 8 changed files with 109 additions and 138 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -359,8 +359,6 @@ public enum DeserializationFeature implements ConfigFeature
* to be equivalent of JSON null.
*<p>
* Feature is disabled by default.
*
* @since 2.5
*/
ACCEPT_EMPTY_ARRAY_AS_NULL_OBJECT(false),

Expand All @@ -373,8 +371,6 @@ public enum DeserializationFeature implements ConfigFeature
* will be thrown.
*<p>
* Feature is enabled by default.
*
* @since 2.6
*/
ACCEPT_FLOAT_AS_INT(true),

Expand All @@ -401,8 +397,6 @@ public enum DeserializationFeature implements ConfigFeature
* cases).
*<p>
* Feature is disabled by default.
*
* @since 2.0
*/
READ_UNKNOWN_ENUM_VALUES_AS_NULL(false),

Expand All @@ -413,8 +407,6 @@ public enum DeserializationFeature implements ConfigFeature
* If enabled, but no predefined default Enum value is specified, an exception will be thrown as well.
*<p>
* Feature is disabled by default.
*
* @since 2.8
*/
READ_UNKNOWN_ENUM_VALUES_USING_DEFAULT_VALUE(false),

Expand All @@ -430,8 +422,6 @@ public enum DeserializationFeature implements ConfigFeature
* This is the counterpart to {@link SerializationFeature#WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS}.
*<p>
* Feature is enabled by default, to support most accurate time values possible.
*
* @since 2.2
*/
READ_DATE_TIMESTAMPS_AS_NANOSECONDS(true),

Expand All @@ -454,8 +444,6 @@ public enum DeserializationFeature implements ConfigFeature
*<p>
* Taking above into account, this feature is supported only by extension modules for
* Joda and Java 8 date/tyime datatypes.
*
* @since 2.2
*/
ADJUST_DATES_TO_CONTEXT_TIME_ZONE(true),

Expand All @@ -476,8 +464,6 @@ public enum DeserializationFeature implements ConfigFeature
* feature: only consider that if there are actual perceived problems.
*<p>
* Feature is enabled by default.
*
* @since 2.1
*/
EAGER_DESERIALIZER_FETCH(true)

Expand Down
24 changes: 0 additions & 24 deletions src/main/java/com/fasterxml/jackson/databind/MapperFeature.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@ public enum MapperFeature implements ConfigFeature
* Feature is disabled by default, meaning that existence of `transient`
* for a field does not necessarily lead to ignoral of getters or setters
* but just ignoring the use of field for access.
*
* @since 2.6
*/
PROPAGATE_TRANSIENT_MARKER(false),

Expand All @@ -83,8 +81,6 @@ public enum MapperFeature implements ConfigFeature
* explicitly annotated for such use.
*<p>
* Feature is enabled by default, for backwards compatibility reasons.
*
* @since 2.2
*/
ALLOW_FINAL_FIELDS_AS_MUTATORS(true),

Expand All @@ -101,8 +97,6 @@ public enum MapperFeature implements ConfigFeature
* bean-style naming) or explicitly annotated.
*<p>
* Feature is enabled by default.
*
* @since 2.2
*/
INFER_PROPERTY_MUTATORS(true),

Expand All @@ -120,8 +114,6 @@ public enum MapperFeature implements ConfigFeature
* for deserialization.
*<p>
* Feature is enabled by default.
*
* @since 2.9
*/
INFER_CREATOR_FROM_CONSTRUCTOR_PROPERTIES(true),

Expand Down Expand Up @@ -170,8 +162,6 @@ public enum MapperFeature implements ConfigFeature
*<p>
* Feature is enabled by default, for legacy reasons (it was the behavior
* until 2.6)
*
* @since 2.7
*/
OVERRIDE_PUBLIC_ACCESS_MODIFIERS(true),

Expand Down Expand Up @@ -262,8 +252,6 @@ public enum MapperFeature implements ConfigFeature
* letters. Overhead for names that are already lower-case should be negligible however.
*<p>
* Feature is disabled by default.
*
* @since 2.5
*/
ACCEPT_CASE_INSENSITIVE_PROPERTIES(false),

Expand All @@ -275,8 +263,6 @@ public enum MapperFeature implements ConfigFeature
* explicit override) do not need to match.
* <p>
* Feature is disabled by default.
*
* @since 2.9
*/
ACCEPT_CASE_INSENSITIVE_ENUMS(false),

Expand All @@ -289,8 +275,6 @@ public enum MapperFeature implements ConfigFeature
* If disabled, wrapper name is only used for wrapping (if anything).
*<p>
* Feature is disabled by default.
*
* @since 2.1
*/
USE_WRAPPER_NAME_AS_PROPERTY_NAME(false),

Expand All @@ -300,8 +284,6 @@ public enum MapperFeature implements ConfigFeature
* be re-named by a {@link PropertyNamingStrategy}, if one is configured.
* <p>
* Feature is disabled by default.
*
* @since 2.7
*/
ALLOW_EXPLICIT_PROPERTY_RENAMING(false),

Expand All @@ -328,8 +310,6 @@ public enum MapperFeature implements ConfigFeature
*<p>
* Feature is enabled by default (for backwards compatibility since this was the
* default behavior)
*
* @since 2.9
*/
ALLOW_COERCION_OF_SCALARS(true),

Expand All @@ -353,8 +333,6 @@ public enum MapperFeature implements ConfigFeature
* this feature is enabled).
*<p>
* Feature is enabled by default.
*
* @since 2.5
*/
IGNORE_DUPLICATE_MODULE_REGISTRATIONS(true),

Expand All @@ -367,8 +345,6 @@ public enum MapperFeature implements ConfigFeature
* Feature is disabled by default since non-mergeable property types are ignored
* even if defaults call for merging, and usually explicit per-type or per-property
* settings for such types should result in an exception.
*
* @since 2.9
*/
IGNORE_MERGE_FOR_UNMERGEABLE(true)

Expand Down
92 changes: 2 additions & 90 deletions src/main/java/com/fasterxml/jackson/databind/ObjectMapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
import com.fasterxml.jackson.databind.introspect.*;
import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatVisitorWrapper;
import com.fasterxml.jackson.databind.jsontype.*;
import com.fasterxml.jackson.databind.jsontype.impl.DefaultTypeResolverBuilder;
import com.fasterxml.jackson.databind.jsontype.impl.StdSubtypeResolver;
import com.fasterxml.jackson.databind.jsontype.impl.StdTypeResolverBuilder;
import com.fasterxml.jackson.databind.node.*;
import com.fasterxml.jackson.databind.ser.*;
import com.fasterxml.jackson.databind.type.*;
Expand Down Expand Up @@ -176,94 +176,6 @@ public enum DefaultTyping {
NON_FINAL
}

/**
* Customized {@link TypeResolverBuilder} that provides type resolver builders
* used with so-called "default typing"
* (see {@link ObjectMapper#enableDefaultTyping()} for details).
*<p>
* Type resolver construction is based on configuration: implementation takes care
* of only providing builders in cases where type information should be applied.
* This is important since build calls may be sent for any and all types, and
* type information should NOT be applied to all of them.
*/
public static class DefaultTypeResolverBuilder
extends StdTypeResolverBuilder
implements java.io.Serializable
{
private static final long serialVersionUID = 1L;

/**
* Definition of what types is this default typer valid for.
*/
protected final DefaultTyping _appliesFor;

public DefaultTypeResolverBuilder(DefaultTyping t) {
_appliesFor = t;
}

@Override
public TypeDeserializer buildTypeDeserializer(DeserializationConfig config,
JavaType baseType, Collection<NamedType> subtypes)
{
return useForType(baseType) ? super.buildTypeDeserializer(config, baseType, subtypes) : null;
}

@Override
public TypeSerializer buildTypeSerializer(SerializationConfig config,
JavaType baseType, Collection<NamedType> subtypes)
{
return useForType(baseType) ? super.buildTypeSerializer(config, baseType, subtypes) : null;
}

/**
* Method called to check if the default type handler should be
* used for given type.
* Note: "natural types" (String, Boolean, Integer, Double) will never
* use typing; that is both due to them being concrete and final,
* and since actual serializers and deserializers will also ignore any
* attempts to enforce typing.
*/
public boolean useForType(JavaType t)
{
// 03-Oct-2016, tatu: As per [databind#1395], need to skip
// primitive types too, regardless
if (t.isPrimitive()) {
return false;
}

switch (_appliesFor) {
case NON_CONCRETE_AND_ARRAYS:
while (t.isArrayType()) {
t = t.getContentType();
}
// fall through
case OBJECT_AND_NON_CONCRETE:
// 19-Apr-2016, tatu: ReferenceType like Optional also requires similar handling:
while (t.isReferenceType()) {
t = t.getReferencedType();
}
return t.isJavaLangObject()
|| (!t.isConcrete()
// [databind#88] Should not apply to JSON tree models:
&& !TreeNode.class.isAssignableFrom(t.getRawClass()));

case NON_FINAL:
while (t.isArrayType()) {
t = t.getContentType();
}
// 19-Apr-2016, tatu: ReferenceType like Optional also requires similar handling:
while (t.isReferenceType()) {
t = t.getReferencedType();
}
// [databind#88] Should not apply to JSON tree models:
return !t.isFinal() && !TreeNode.class.isAssignableFrom(t.getRawClass());
default:
//case JAVA_LANG_OBJECT:
return t.isJavaLangObject();
}
}
}

/*
/**********************************************************
/* Internal constants, singletons
Expand Down Expand Up @@ -436,7 +348,7 @@ public boolean useForType(JavaType t)
* (should very quickly converge to zero after startup), let's
* explicitly define a low concurrency setting.
*<p>
* Since version 1.5, these may are either "raw" deserializers (when
* These may are either "raw" deserializers (when
* no type information is needed for base type), or type-wrapped
* deserializers (if it is needed)
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,12 @@
public final class BaseSettings
implements java.io.Serializable
{
// for 2.6
private static final long serialVersionUID = 1L;

/**
* We will use a default TimeZone as the baseline.
*/
private static final TimeZone DEFAULT_TIMEZONE =
// TimeZone.getDefault()
/* [databind#915] 05-Nov-2015, tatu: Changed to UTC, from earlier
* baseline of GMT (up to 2.6)
*/
TimeZone.getTimeZone("UTC");

/*
Expand Down
Loading

0 comments on commit f3ba50c

Please sign in to comment.