Skip to content

Commit

Permalink
yet more test coverage work
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Oct 20, 2016
1 parent a419de2 commit 7912486
Show file tree
Hide file tree
Showing 11 changed files with 319 additions and 191 deletions.
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -114,15 +114,6 @@ public DeserializationConfig(BaseSettings base,
_formatReadFeaturesToChange = 0; _formatReadFeaturesToChange = 0;
} }


/**
* @deprecated Since 2.8, remove from 2.9 or later
*/
@Deprecated
public DeserializationConfig(BaseSettings base, SubtypeResolver str,
SimpleMixInResolver mixins, RootNameLookup rootNames) {
this(base, str, mixins, rootNames, null);
}

private DeserializationConfig(DeserializationConfig src, private DeserializationConfig(DeserializationConfig src,
int mapperFeatures, int deserFeatures, int mapperFeatures, int deserFeatures,
int parserFeatures, int parserFeatureMask, int parserFeatures, int parserFeatureMask,
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -688,19 +688,6 @@ public JsonDeserializer<?> handleSecondaryContextualization(JsonDeserializer<?>
return deser; return deser;
} }


@Deprecated // since 2.5; remove from 2.9
public JsonDeserializer<?> handlePrimaryContextualization(JsonDeserializer<?> deser, BeanProperty prop) throws JsonMappingException {
return handlePrimaryContextualization(deser, prop, TypeFactory.unknownType());
}

@Deprecated // since 2.5; remove from 2.9
public JsonDeserializer<?> handleSecondaryContextualization(JsonDeserializer<?> deser, BeanProperty prop) throws JsonMappingException {
if (deser instanceof ContextualDeserializer) {
deser = ((ContextualDeserializer) deser).createContextual(this, prop);
}
return deser;
}

/* /*
/********************************************************** /**********************************************************
/* Parsing methods that may use reusable/-cyclable objects /* Parsing methods that may use reusable/-cyclable objects
Expand Down Expand Up @@ -862,9 +849,7 @@ public Object handleWeirdKey(Class<?> keyClass, String keyValue,
throws IOException throws IOException
{ {
// but if not handled, just throw exception // but if not handled, just throw exception
if (msgArgs.length > 0) { msg = _format(msg, msgArgs);
msg = String.format(msg, msgArgs);
}
LinkedNode<DeserializationProblemHandler> h = _config.getProblemHandlers(); LinkedNode<DeserializationProblemHandler> h = _config.getProblemHandlers();
while (h != null) { while (h != null) {
// Can bail out if it's handled // Can bail out if it's handled
Expand Down Expand Up @@ -908,9 +893,7 @@ public Object handleWeirdStringValue(Class<?> targetClass, String value,
throws IOException throws IOException
{ {
// but if not handled, just throw exception // but if not handled, just throw exception
if (msgArgs.length > 0) { msg = _format(msg, msgArgs);
msg = String.format(msg, msgArgs);
}
LinkedNode<DeserializationProblemHandler> h = _config.getProblemHandlers(); LinkedNode<DeserializationProblemHandler> h = _config.getProblemHandlers();
while (h != null) { while (h != null) {
// Can bail out if it's handled // Can bail out if it's handled
Expand Down Expand Up @@ -953,9 +936,7 @@ public Object handleWeirdNumberValue(Class<?> targetClass, Number value,
String msg, Object... msgArgs) String msg, Object... msgArgs)
throws IOException throws IOException
{ {
if (msgArgs.length > 0) { msg = _format(msg, msgArgs);
msg = String.format(msg, msgArgs);
}
LinkedNode<DeserializationProblemHandler> h = _config.getProblemHandlers(); LinkedNode<DeserializationProblemHandler> h = _config.getProblemHandlers();
while (h != null) { while (h != null) {
// Can bail out if it's handled // Can bail out if it's handled
Expand Down Expand Up @@ -999,9 +980,7 @@ public Object handleMissingInstantiator(Class<?> instClass, ValueInstantiator va
if (p == null) { if (p == null) {
p = getParser(); p = getParser();
} }
if (msgArgs.length > 0) { msg = _format(msg, msgArgs);
msg = String.format(msg, msgArgs);
}
LinkedNode<DeserializationProblemHandler> h = _config.getProblemHandlers(); LinkedNode<DeserializationProblemHandler> h = _config.getProblemHandlers();
while (h != null) { while (h != null) {
// Can bail out if it's handled // Can bail out if it's handled
Expand Down Expand Up @@ -1115,9 +1094,7 @@ public Object handleUnexpectedToken(Class<?> instClass, JsonToken t,
String msg, Object... msgArgs) String msg, Object... msgArgs)
throws IOException throws IOException
{ {
if (msgArgs.length > 0) { msg = _format(msg, msgArgs);
msg = String.format(msg, msgArgs);
}
LinkedNode<DeserializationProblemHandler> h = _config.getProblemHandlers(); LinkedNode<DeserializationProblemHandler> h = _config.getProblemHandlers();
while (h != null) { while (h != null) {
Object instance = h.value().handleUnexpectedToken(this, Object instance = h.value().handleUnexpectedToken(this,
Expand Down Expand Up @@ -1213,9 +1190,7 @@ public void reportWrongTokenException(JsonDeserializer<?> deser,
JsonToken expToken, String msg, Object... msgArgs) JsonToken expToken, String msg, Object... msgArgs)
throws JsonMappingException throws JsonMappingException
{ {
if ((msg != null) && (msgArgs.length > 0)) { msg = _format(msg, msgArgs);
msg = String.format(msg, msgArgs);
}
throw wrongTokenException(getParser(), deser.handledType(), expToken, msg); throw wrongTokenException(getParser(), deser.handledType(), expToken, msg);
} }


Expand All @@ -1233,9 +1208,7 @@ public void reportWrongTokenException(JavaType targetType,
JsonToken expToken, String msg, Object... msgArgs) JsonToken expToken, String msg, Object... msgArgs)
throws JsonMappingException throws JsonMappingException
{ {
if ((msg != null) && (msgArgs.length > 0)) { msg = _format(msg, msgArgs);
msg = String.format(msg, msgArgs);
}
throw wrongTokenException(getParser(), targetType, expToken, msg); throw wrongTokenException(getParser(), targetType, expToken, msg);
} }


Expand All @@ -1253,9 +1226,7 @@ public void reportWrongTokenException(Class<?> targetType,
JsonToken expToken, String msg, Object... msgArgs) JsonToken expToken, String msg, Object... msgArgs)
throws JsonMappingException throws JsonMappingException
{ {
if ((msg != null) && (msgArgs.length > 0)) { msg = _format(msg, msgArgs);
msg = String.format(msg, msgArgs);
}
throw wrongTokenException(getParser(), targetType, expToken, msg); throw wrongTokenException(getParser(), targetType, expToken, msg);
} }


Expand All @@ -1264,9 +1235,7 @@ public void reportWrongTokenException(JsonParser p,
JsonToken expToken, String msg, Object... msgArgs) JsonToken expToken, String msg, Object... msgArgs)
throws JsonMappingException throws JsonMappingException
{ {
if ((msg != null) && (msgArgs.length > 0)) { msg = _format(msg, msgArgs);
msg = String.format(msg, msgArgs);
}
throw wrongTokenException(p, expToken, msg); throw wrongTokenException(p, expToken, msg);
} }


Expand Down Expand Up @@ -1306,8 +1275,8 @@ public void reportMissingContent(String msg, Object... msgArgs)
{ {
if (msg == null) { if (msg == null) {
msg = "No content to map due to end-of-input"; msg = "No content to map due to end-of-input";
} else if (msgArgs.length > 0) { } else {
msg = String.format(msg, msgArgs); msg = _format(msg, msgArgs);
} }
throw InputMismatchException.from(getParser(), (JavaType) null, msg); throw InputMismatchException.from(getParser(), (JavaType) null, msg);
} }
Expand All @@ -1332,9 +1301,7 @@ public <T> T reportUnresolvedObjectId(ObjectIdReader oidReader, Object bean)
public <T> T reportInputMismatch(BeanProperty prop, public <T> T reportInputMismatch(BeanProperty prop,
String msg, Object... msgArgs) throws JsonMappingException String msg, Object... msgArgs) throws JsonMappingException
{ {
if (msgArgs.length > 0) { msg = _format(msg, msgArgs);
msg = String.format(msg, msgArgs);
}
throw InputMismatchException.from(getParser(), prop.getType(), msg); throw InputMismatchException.from(getParser(), prop.getType(), msg);
} }


Expand All @@ -1347,9 +1314,7 @@ public <T> T reportInputMismatch(BeanProperty prop,
public <T> T reportInputMismatch(JsonDeserializer<?> src, public <T> T reportInputMismatch(JsonDeserializer<?> src,
String msg, Object... msgArgs) throws JsonMappingException String msg, Object... msgArgs) throws JsonMappingException
{ {
if (msgArgs.length > 0) { msg = _format(msg, msgArgs);
msg = String.format(msg, msgArgs);
}
throw InputMismatchException.from(getParser(), src.handledType(), msg); throw InputMismatchException.from(getParser(), src.handledType(), msg);
} }


Expand All @@ -1362,9 +1327,7 @@ public <T> T reportInputMismatch(JsonDeserializer<?> src,
public <T> T reportInputMismatch(Class<?> targetType, public <T> T reportInputMismatch(Class<?> targetType,
String msg, Object... msgArgs) throws JsonMappingException String msg, Object... msgArgs) throws JsonMappingException
{ {
if (msgArgs.length > 0) { msg = _format(msg, msgArgs);
msg = String.format(msg, msgArgs);
}
throw InputMismatchException.from(getParser(), targetType, msg); throw InputMismatchException.from(getParser(), targetType, msg);
} }


Expand All @@ -1377,9 +1340,7 @@ public <T> T reportInputMismatch(Class<?> targetType,
public <T> T reportInputMismatch(JavaType targetType, public <T> T reportInputMismatch(JavaType targetType,
String msg, Object... msgArgs) throws JsonMappingException String msg, Object... msgArgs) throws JsonMappingException
{ {
if (msgArgs.length > 0) { msg = _format(msg, msgArgs);
msg = String.format(msg, msgArgs);
}
throw InputMismatchException.from(getParser(), targetType, msg); throw InputMismatchException.from(getParser(), targetType, msg);
} }


Expand Down Expand Up @@ -1450,24 +1411,20 @@ public <T> T reportBadDefinition(JavaType type, String msg) throws JsonMappingEx
* @since 2.9 * @since 2.9
*/ */
public JsonMappingException wrongTokenException(JsonParser p, JavaType targetType, public JsonMappingException wrongTokenException(JsonParser p, JavaType targetType,
JsonToken expToken, String msg0) JsonToken expToken, String extra)
{ {
String msg = String.format("Unexpected token (%s), expected %s", String msg = String.format("Unexpected token (%s), expected %s",
p.getCurrentToken(), expToken); p.getCurrentToken(), expToken);
if (msg0 != null) { msg = _colonConcat(msg, extra);
msg = msg + ": "+msg0;
}
return InputMismatchException.from(p, targetType, msg); return InputMismatchException.from(p, targetType, msg);
} }


public JsonMappingException wrongTokenException(JsonParser p, Class<?> targetType, public JsonMappingException wrongTokenException(JsonParser p, Class<?> targetType,
JsonToken expToken, String msg0) JsonToken expToken, String extra)
{ {
String msg = String.format("Unexpected token (%s), expected %s", String msg = String.format("Unexpected token (%s), expected %s",
p.getCurrentToken(), expToken); p.getCurrentToken(), expToken);
if (msg0 != null) { msg = _colonConcat(msg, extra);
msg = msg + ": "+msg0;
}
return InputMismatchException.from(p, targetType, msg); return InputMismatchException.from(p, targetType, msg);
} }


Expand Down Expand Up @@ -1578,9 +1535,7 @@ public JsonMappingException unknownTypeIdException(JavaType baseType, String typ
String extraDesc) { String extraDesc) {
String msg = String.format("Could not resolve type id '%s' into a subtype of %s", String msg = String.format("Could not resolve type id '%s' into a subtype of %s",
typeId, baseType); typeId, baseType);
if (extraDesc != null) { msg = _colonConcat(msg, extraDesc);
msg = msg + ": "+extraDesc;
}
return InvalidTypeIdException.from(_parser, msg, baseType, typeId); return InvalidTypeIdException.from(_parser, msg, baseType, typeId);
} }


Expand All @@ -1600,9 +1555,7 @@ public JsonMappingException unknownTypeException(JavaType type, String id,
String extraDesc) { String extraDesc) {
String msg = String.format("Could not resolve type id '%s' into a subtype of %s", String msg = String.format("Could not resolve type id '%s' into a subtype of %s",
id, type); id, type);
if (extraDesc != null) { msg = _colonConcat(msg, extraDesc);
msg = msg + ": "+extraDesc;
}
return InputMismatchException.from(_parser, type, msg); return InputMismatchException.from(_parser, type, msg);
} }


Expand Down Expand Up @@ -1639,9 +1592,7 @@ public JsonMappingException endOfInputException(Class<?> instClass) {
public void reportMappingException(String msg, Object... msgArgs) public void reportMappingException(String msg, Object... msgArgs)
throws JsonMappingException throws JsonMappingException
{ {
if (msgArgs.length > 0) { msg = _format(msg, msgArgs);
msg = String.format(msg, msgArgs);
}
throw JsonMappingException.from(getParser(), msg); throw JsonMappingException.from(getParser(), msg);
} }


Expand Down Expand Up @@ -1765,4 +1716,20 @@ protected String _quotedString(String desc) {
} }
return "\"" + desc + "\""; return "\"" + desc + "\"";
} }

// @since 2.9
protected String _colonConcat(String msgBase, String extra) {
if (extra == null) {
return msgBase;
}
return msgBase + ": " + extra;
}

// @since 2.9
protected String _format(String msg, Object... msgArgs) {
if (msgArgs.length > 0) {
return String.format(msg, msgArgs);
}
return msg;
}
} }
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ public Iterator<PropertyWriter> properties() {
public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType type) public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType type)
throws JsonMappingException throws JsonMappingException
{ {
if (visitor != null) visitor.expectAnyFormat(type); visitor.expectAnyFormat(type);
} }


/* /*
Expand Down
17 changes: 0 additions & 17 deletions src/main/java/com/fasterxml/jackson/databind/PropertyMetadata.java
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@ public class PropertyMetadata
/* Construction, configuration /* Construction, configuration
/********************************************************** /**********************************************************
*/ */

@Deprecated // since 2.4
protected PropertyMetadata(Boolean req, String desc) { this(req, desc, null, null); }


/** /**
* @since 2.5 * @since 2.5
Expand All @@ -64,14 +61,6 @@ protected PropertyMetadata(Boolean req, String desc, Integer index, String def)
_defaultValue = (def == null || def.isEmpty()) ? null : def; _defaultValue = (def == null || def.isEmpty()) ? null : def;
} }


/**
* @since 2.4 Use variant that takes more arguments.
*/
@Deprecated
public static PropertyMetadata construct(boolean req, String desc) {
return construct(req, desc, null, null);
}

public static PropertyMetadata construct(boolean req, String desc, Integer index, public static PropertyMetadata construct(boolean req, String desc, Integer index,
String defaultValue) { String defaultValue) {
if (desc != null || index != null || defaultValue != null) { if (desc != null || index != null || defaultValue != null) {
Expand Down Expand Up @@ -141,12 +130,6 @@ public PropertyMetadata withRequired(Boolean b) {
*/ */
public String getDefaultValue() { return _defaultValue; } public String getDefaultValue() { return _defaultValue; }


/**
* @deprecated Since 2.6: typo in name, use {@link #hasDefaultValue()} instead.
*/
@Deprecated
public boolean hasDefuaultValue() { return hasDefaultValue(); }

/** /**
* Accessor for determining whether property has declared "default value", * Accessor for determining whether property has declared "default value",
* which may be used by extension modules. * which may be used by extension modules.
Expand Down
Loading

0 comments on commit 7912486

Please sign in to comment.