All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.mokung.pomegranate.jackson.handler.getter.StringGetter Maven / Gradle / Ivy

There is a newer version: 1.0.2
Show newest version
package com.mokung.pomegranate.jackson.handler.getter;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.NullNode;
import com.fasterxml.jackson.databind.node.TextNode;
import com.mokung.pomegranate.jackson.handler.Getter;

/**
 *
 * @author mokung
 */
public class StringGetter implements Getter {

    @Override
    public String getter(JsonNode valueNode, ObjectMapper mapper, boolean cast) {
        if (valueNode instanceof TextNode) {
            return valueNode.asText();
        }
        if (!cast || valueNode == null || valueNode instanceof NullNode) {
            return null;
        }
        return valueNode.asText();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy