Skip to content

Commit

Permalink
First 3.0 changes: sync with changes from annotations, core (rm of de…
Browse files Browse the repository at this point in the history
…precated); some small deprecation rm here too
  • Loading branch information
cowtowncoder committed Aug 8, 2017
1 parent 3e59fae commit c6a991d
Show file tree
Hide file tree
Showing 53 changed files with 239 additions and 398 deletions.
18 changes: 10 additions & 8 deletions pom.xml
Expand Up @@ -10,7 +10,7 @@

<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.9.1-SNAPSHOT</version>
<version>3.0.0-SNAPSHOT</version>
<name>jackson-databind</name>
<packaging>bundle</packaging>
<description>General data-binding functionality for Jackson: works on core streaming API</description>
Expand All @@ -25,14 +25,10 @@
</scm>

<properties>
<!-- With Jackson 2.9 we will require JDK 7 (except for annotations/streaming),
and new language features (diamond pattern) may be used.
JDK classes are still loaded dynamically since there isn't much downside
(small number of types); this allows use on JDK 6 platforms still (including
Android)
<!-- Jackson 3.x requires Java 8
-->
<javac.src.version>1.7</javac.src.version>
<javac.target.version>1.7</javac.target.version>
<javac.src.version>1.8</javac.src.version>
<javac.target.version>1.8</javac.target.version>

<!-- Can not use default, since group id != Java package name here -->
<osgi.export>com.fasterxml.jackson.databind.*;version=${project.version}</osgi.export>
Expand All @@ -52,12 +48,18 @@
usage seems to benefit from actually specifying version here in case
it is dependent on transitively
-->
<!--
<version>${jackson.version.annotations}</version>
-->
<version>3.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>3.0.0-SNAPSHOT</version>
<!--
<version>${jackson.version.core}</version>
-->
</dependency>

<!-- and for testing we need a few libraries
Expand Down
Expand Up @@ -1089,7 +1089,7 @@ public Object handleInstantiationProblem(Class<?> instClass, Object argument,
public Object handleUnexpectedToken(Class<?> instClass, JsonParser p)
throws IOException
{
return handleUnexpectedToken(instClass, p.getCurrentToken(), p, null);
return handleUnexpectedToken(instClass, p.currentToken(), p, null);
}

/**
Expand Down Expand Up @@ -1480,7 +1480,7 @@ public JsonMappingException wrongTokenException(JsonParser p, JavaType targetTyp
JsonToken expToken, String extra)
{
String msg = String.format("Unexpected token (%s), expected %s",
p.getCurrentToken(), expToken);
p.currentToken(), expToken);
msg = _colonConcat(msg, extra);
return MismatchedInputException.from(p, targetType, msg);
}
Expand All @@ -1489,7 +1489,7 @@ public JsonMappingException wrongTokenException(JsonParser p, Class<?> targetTyp
JsonToken expToken, String extra)
{
String msg = String.format("Unexpected token (%s), expected %s",
p.getCurrentToken(), expToken);
p.currentToken(), expToken);
msg = _colonConcat(msg, extra);
return MismatchedInputException.from(p, targetType, msg);
}
Expand Down Expand Up @@ -1625,115 +1625,6 @@ public JsonMappingException missingTypeIdException(JavaType baseType,
return InvalidTypeIdException.from(_parser, _colonConcat(msg, extraDesc), baseType, null);
}

/*
/**********************************************************
/* Deprecated exception factory methods
/**********************************************************
*/

/**
* @since 2.5
*
* @deprecated Since 2.8 use {@link #handleUnknownTypeId} instead
*/
@Deprecated
public JsonMappingException unknownTypeException(JavaType type, String id,
String extraDesc)
{
String msg = String.format("Could not resolve type id '%s' into a subtype of %s",
id, type);
msg = _colonConcat(msg, extraDesc);
return MismatchedInputException.from(_parser, type, msg);
}

/**
* Helper method for constructing exception to indicate that end-of-input was
* reached while still expecting more tokens to deserialize value of specified type.
*
* @deprecated Since 2.8; currently no way to catch EOF at databind level
*/
@Deprecated
public JsonMappingException endOfInputException(Class<?> instClass) {
return MismatchedInputException.from(_parser, instClass,
"Unexpected end-of-input when trying to deserialize a "+instClass.getName());
}

/*
/**********************************************************
/* Deprecated methods for constructing, throwing non-specific
/* JsonMappingExceptions: as of 2.9, should use more specific
/* ones.
/**********************************************************
*/

/**
* Fallback method that may be called if no other <code>reportXxx</code>
* is applicable -- but only in that case.
*
* @since 2.8
*
* @deprecated Since 2.9: use a more specific method, or {@link #reportBadDefinition(JavaType, String)},
* or {@link #reportInputMismatch} instead
*/
@Deprecated // since 2.9
public void reportMappingException(String msg, Object... msgArgs)
throws JsonMappingException
{
throw JsonMappingException.from(getParser(), _format(msg, msgArgs));
}

/**
* Helper method for constructing generic mapping exception with specified
* message and current location information.
* Note that application code should almost always call
* one of <code>handleXxx</code> methods, or {@link #reportMappingException(String, Object...)}
* instead.
*
* @since 2.6
*
* @deprecated Since 2.9 use more specific error reporting methods instead
*/
@Deprecated
public JsonMappingException mappingException(String message) {
return JsonMappingException.from(getParser(), message);
}

/**
* Helper method for constructing generic mapping exception with specified
* message and current location information
* Note that application code should almost always call
* one of <code>handleXxx</code> methods, or {@link #reportMappingException(String, Object...)}
* instead.
*
* @since 2.6
*
* @deprecated Since 2.9 use more specific error reporting methods instead
*/
@Deprecated
public JsonMappingException mappingException(String msg, Object... msgArgs) {
return JsonMappingException.from(getParser(), _format(msg, msgArgs));
}

/**
* Helper method for constructing generic mapping exception for specified type
*
* @deprecated Since 2.8 use {@link #handleUnexpectedToken(Class, JsonParser)} instead
*/
@Deprecated
public JsonMappingException mappingException(Class<?> targetClass) {
return mappingException(targetClass, _parser.getCurrentToken());
}

/**
* @deprecated Since 2.8 use {@link #handleUnexpectedToken(Class, JsonParser)} instead
*/
@Deprecated
public JsonMappingException mappingException(Class<?> targetClass, JsonToken token) {
return JsonMappingException.from(_parser,
String.format("Cannot deserialize instance of %s out of %s token",
_calcName(targetClass), token));
}

/*
/**********************************************************
/* Other internal methods
Expand Down
10 changes: 0 additions & 10 deletions src/main/java/com/fasterxml/jackson/databind/JavaType.java
Expand Up @@ -366,16 +366,6 @@ public boolean isConcrete() {

@Override
public abstract JavaType containedType(int index);

@Deprecated // since 2.7
@Override
public abstract String containedTypeName(int index);

@Deprecated // since 2.7
@Override
public Class<?> getParameterSource() {
return null;
}

/*
/**********************************************************
Expand Down
Expand Up @@ -152,7 +152,7 @@ protected MappingIterator(JavaType type, JsonParser p, DeserializationContext ct
// regardless, recovery context should be whatever context we have now,
// with sole exception of pointing to a start marker, in which case it's
// the parent
JsonToken t = p.getCurrentToken();
JsonToken t = p.currentToken();
if ((t == JsonToken.START_OBJECT) || (t == JsonToken.START_ARRAY)) {
sctxt = sctxt.getParent();
}
Expand Down Expand Up @@ -235,7 +235,7 @@ public boolean hasNextValue() throws IOException
_resync();
// fall-through
case STATE_MAY_HAVE_VALUE:
JsonToken t = _parser.getCurrentToken();
JsonToken t = _parser.currentToken();
if (t == null) { // un-initialized or cleared; find next
t = _parser.nextToken();
// If EOF, no more, or if we hit END_ARRAY (although we don't clear the token).
Expand Down
21 changes: 7 additions & 14 deletions src/main/java/com/fasterxml/jackson/databind/ObjectMapper.java
Expand Up @@ -1832,13 +1832,6 @@ public ObjectMapper setConfig(SerializationConfig config) {
*/
@Override
public JsonFactory getFactory() { return _jsonFactory; }

/**
* @deprecated Since 2.1: Use {@link #getFactory} instead
*/
@Deprecated
@Override
public JsonFactory getJsonFactory() { return getFactory(); }

/**
* Method for configuring the default {@link DateFormat} to use when serializing time
Expand Down Expand Up @@ -2362,7 +2355,7 @@ public <T extends TreeNode> T readTree(JsonParser p)
* calling readValue(), since that'll choke on it otherwise
*/
DeserializationConfig cfg = getDeserializationConfig();
JsonToken t = p.getCurrentToken();
JsonToken t = p.currentToken();
if (t == null) {
t = p.nextToken();
if (t == null) {
Expand Down Expand Up @@ -4025,7 +4018,7 @@ protected JsonNode _readTreeAndClose(JsonParser p0) throws IOException
// special requirements by tree reading (no fail on eof)

cfg.initialize(p); // since 2.5
JsonToken t = p.getCurrentToken();
JsonToken t = p.currentToken();
if (t == null) {
t = p.nextToken();
if (t == null) { // [databind#1406]: expose end-of-input as `null`
Expand Down Expand Up @@ -4060,16 +4053,16 @@ protected Object _unwrapAndDeserialize(JsonParser p, DeserializationContext ctxt
PropertyName expRootName = config.findRootName(rootType);
// 12-Jun-2015, tatu: Should try to support namespaces etc but...
String expSimpleName = expRootName.getSimpleName();
if (p.getCurrentToken() != JsonToken.START_OBJECT) {
if (p.currentToken() != JsonToken.START_OBJECT) {
ctxt.reportWrongTokenException(rootType, JsonToken.START_OBJECT,
"Current token not START_OBJECT (needed to unwrap root name '%s'), but %s",
expSimpleName, p.getCurrentToken());
expSimpleName, p.currentToken());

}
if (p.nextToken() != JsonToken.FIELD_NAME) {
ctxt.reportWrongTokenException(rootType, JsonToken.FIELD_NAME,
"Current token not FIELD_NAME (to contain expected root name '"
+expSimpleName+"'), but "+p.getCurrentToken());
+expSimpleName+"'), but "+p.currentToken());
}
String actualName = p.getCurrentName();
if (!expSimpleName.equals(actualName)) {
Expand All @@ -4084,7 +4077,7 @@ protected Object _unwrapAndDeserialize(JsonParser p, DeserializationContext ctxt
if (p.nextToken() != JsonToken.END_OBJECT) {
ctxt.reportWrongTokenException(rootType, JsonToken.END_OBJECT,
"Current token not END_OBJECT (to match wrapper object with root name '%s'), but %s",
expSimpleName, p.getCurrentToken());
expSimpleName, p.currentToken());
}
if (config.isEnabled(DeserializationFeature.FAIL_ON_TRAILING_TOKENS)) {
_verifyNoTrailingTokens(p, ctxt, rootType);
Expand Down Expand Up @@ -4124,7 +4117,7 @@ protected JsonToken _initForReading(JsonParser p, JavaType targetType) throws IO
// First: must point to a token; if not pointing to one, advance.
// This occurs before first read from JsonParser, as well as
// after clearing of current token.
JsonToken t = p.getCurrentToken();
JsonToken t = p.currentToken();
if (t == null) {
// and then we must get something...
t = p.nextToken();
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/com/fasterxml/jackson/databind/ObjectReader.java
Expand Up @@ -350,7 +350,7 @@ protected JsonToken _initForReading(DeserializationContext ctxt, JsonParser p)
* This occurs before first read from JsonParser, as well as
* after clearing of current token.
*/
JsonToken t = p.getCurrentToken();
JsonToken t = p.currentToken();
if (t == null) { // and then we must get something...
t = p.nextToken();
if (t == null) {
Expand Down Expand Up @@ -1635,7 +1635,7 @@ protected final JsonNode _bindAsTree(JsonParser p) throws IOException
p.setSchema(_schema);
}

JsonToken t = p.getCurrentToken();
JsonToken t = p.currentToken();
if (t == null) {
t = p.nextToken();
if (t == null) { // [databind#1406]: expose end-of-input as `null`
Expand Down Expand Up @@ -1677,15 +1677,15 @@ protected Object _unwrapAndDeserialize(JsonParser p, DeserializationContext ctxt
// 12-Jun-2015, tatu: Should try to support namespaces etc but...
String expSimpleName = expRootName.getSimpleName();

if (p.getCurrentToken() != JsonToken.START_OBJECT) {
if (p.currentToken() != JsonToken.START_OBJECT) {
ctxt.reportWrongTokenException(rootType, JsonToken.START_OBJECT,
"Current token not START_OBJECT (needed to unwrap root name '%s'), but %s",
expSimpleName, p.getCurrentToken());
expSimpleName, p.currentToken());
}
if (p.nextToken() != JsonToken.FIELD_NAME) {
ctxt.reportWrongTokenException(rootType, JsonToken.FIELD_NAME,
"Current token not FIELD_NAME (to contain expected root name '%s'), but %s",
expSimpleName, p.getCurrentToken());
expSimpleName, p.currentToken());
}
String actualName = p.getCurrentName();
if (!expSimpleName.equals(actualName)) {
Expand All @@ -1706,7 +1706,7 @@ protected Object _unwrapAndDeserialize(JsonParser p, DeserializationContext ctxt
if (p.nextToken() != JsonToken.END_OBJECT) {
ctxt.reportWrongTokenException(rootType, JsonToken.END_OBJECT,
"Current token not END_OBJECT (to match wrapper object with root name '%s'), but %s",
expSimpleName, p.getCurrentToken());
expSimpleName, p.currentToken());
}
if (_config.isEnabled(DeserializationFeature.FAIL_ON_TRAILING_TOKENS)) {
_verifyNoTrailingTokens(p, ctxt, _valueType);
Expand Down
Expand Up @@ -230,7 +230,7 @@ public Object deserializeWithType(JsonParser p, DeserializationContext ctxt,
// Hmmh. One tricky question; for scalar, is it an Object Id, or "Natural" type?
// for now, prefer Object Id:
if (_objectIdReader != null) {
JsonToken t = p.getCurrentToken();
JsonToken t = p.currentToken();
if (t != null) {
// Most commonly, a scalar (int id, uuid String, ...)
if (t.isScalarValue()) {
Expand Down Expand Up @@ -280,7 +280,7 @@ protected Object _deserializeIfNatural(JsonParser p, DeserializationContext ctxt
* Finally, we may have to consider possibility of custom handlers for
* these values: but for now this should work ok.
*/
switch (p.getCurrentTokenId()) {
switch (p.currentTokenId()) {
case JsonTokenId.ID_STRING:
if (_acceptString) {
return p.getText();
Expand Down

0 comments on commit c6a991d

Please sign in to comment.