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

com.icthh.xm.commons.permission.config.SpelDeserializer Maven / Gradle / Ivy

There is a newer version: 4.0.17
Show newest version
package com.icthh.xm.commons.permission.config;

import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
import org.springframework.expression.Expression;
import org.springframework.expression.ExpressionParser;
import org.springframework.expression.spel.standard.SpelExpressionParser;

import java.io.IOException;

public class SpelDeserializer extends StdDeserializer {

    private transient ExpressionParser parser = new SpelExpressionParser();

    public SpelDeserializer() {
        this(null);
    }

    protected SpelDeserializer(Class dc) {
        super(dc);
    }

    @Override
    public Expression deserialize(JsonParser jp, DeserializationContext context) throws IOException {
        String expressionString = jp.getCodec().readValue(jp, String.class);
        return parser.parseExpression(expressionString);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy