com.ppiech.auto.value.jackson.internal.objectmappers.LongMapper Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jackson-auto Show documentation
Show all versions of jackson-auto Show documentation
AutoValue extension for serializing with Jasckon
package com.ppiech.auto.value.jackson.internal.objectmappers;
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 Long objects
*/
public class LongMapper extends com.ppiech.auto.value.jackson.JsonMapper {
@Override
public Long parse(JsonParser jsonParser) throws IOException {
if (jsonParser.getCurrentToken() == JsonToken.VALUE_NULL) {
return null;
} else {
return jsonParser.getLongValue();
}
}
@Override
public void parseField(Long instance, String fieldName, JsonParser jsonParser) throws IOException { }
@Override
public void serialize(Long object, JsonGenerator generator, boolean writeStartAndEnd) throws IOException {
generator.writeNumber(object);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy