com.ppiech.auto.value.jackson.internal.objectmappers.DoubleMapper Maven / Gradle / Ivy
package com.ppiech.auto.value.jackson.internal.objectmappers;
import com.ppiech.auto.value.jackson.JsonMapper;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonToken;
import java.io.IOException;
/**
* Built-in mapper for Double objects
*/
public class DoubleMapper extends JsonMapper {
@Override
public Double parse(JsonParser jsonParser) throws IOException {
if (jsonParser.getCurrentToken() == JsonToken.VALUE_NULL) {
return null;
} else {
return jsonParser.getDoubleValue();
}
}
@Override
public void parseField(Double instance, String fieldName, JsonParser jsonParser) throws IOException { }
@Override
public void serialize(Double object, JsonGenerator generator, boolean writeStartAndEnd) throws IOException {
generator.writeNumber(object);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy