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

com.doyospy.core.helper.IdDeserializer Maven / Gradle / Ivy

Go to download

Doyospy是一个小而全的基于SpringBoot的java工具类库,通过静态方法封装,方便开发者使用,降低学习成本并提升工作效率。

The newest version!
package com.doyospy.core.helper;

import com.doyospy.core.util.IdUtil;
import com.fasterxml.jackson.core.JacksonException;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
import java.io.IOException;
import java.util.Objects;

/**
 * ID反序列化
 * @author  Robin
 */
public class IdDeserializer extends JsonDeserializer {
    @Override
    public Object deserialize(JsonParser p, DeserializationContext ctxt) throws IOException, JacksonException {
        if (Objects.isNull(p)) {
            return null;
        }
        return IdUtil.decode(p.getText());
    }
}