DATACOUCH-159 - Improved performance of decoding of longs.

Original pull requests: #67.
Cherry-pick of e5bed8e, adapted with polishing from 6fec488.
This commit is contained in:
Simon Baslé
2015-08-31 19:04:01 +02:00
parent 411eb1c463
commit 89e56d6342
2 changed files with 44 additions and 25 deletions

View File

@@ -23,7 +23,6 @@ import java.util.Map;
import com.fasterxml.jackson.core.JsonFactory;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonToken;
import com.fasterxml.jackson.databind.ObjectMapper;
@@ -39,6 +38,8 @@ import org.springframework.data.mapping.model.SimpleTypeHolder;
* A Jackson JSON Translator that implements the {@link TranslationService} contract.
*
* @author Michael Nitschinger
* @author Simon Baslé
* @author Anastasiia Smirnova
*/
public class JacksonTranslationService implements TranslationService, InitializingBean {
@@ -221,18 +222,13 @@ public class JacksonTranslationService implements TranslationService, Initializi
switch (token) {
case VALUE_TRUE:
case VALUE_FALSE:
return parser.getValueAsBoolean();
return parser.getBooleanValue();
case VALUE_STRING:
return parser.getValueAsString();
case VALUE_NUMBER_INT:
try {
return parser.getValueAsInt();
}
catch (final JsonParseException e) {
return parser.getValueAsLong();
}
return parser.getNumberValue();
case VALUE_NUMBER_FLOAT:
return parser.getValueAsDouble();
return parser.getDoubleValue();
case VALUE_NULL:
return null;
default: