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

com.dream.system.antlr.handler.page.PageAction Maven / Gradle / Ivy

package com.dream.system.antlr.handler.page;


import com.dream.system.config.MappedStatement;
import com.dream.system.config.MethodInfo;
import com.dream.system.core.action.InitAction;
import com.dream.system.core.session.Session;
import com.dream.util.common.ObjectMap;
import com.dream.util.common.ObjectWrapper;

import java.util.Map;

public class PageAction implements InitAction {
    private MethodInfo methodInfo;
    private String property;

    public PageAction(MethodInfo methodInfo, String property) {
        this.methodInfo = methodInfo;
        this.property = property;
    }

    @Override
    public void init(MappedStatement mappedStatement, Session session) {
        Object arg = mappedStatement.getArg();
        Map argMap;
        if (arg instanceof Map) {
            argMap = (Map) arg;
        } else {
            argMap = new ObjectMap(arg);
        }
        ObjectWrapper wrapper = ObjectWrapper.wrapper(arg);
        long total = (long) wrapper.get(property);
        if (total == 0) {
            Object result = session.execute(methodInfo, argMap);
            wrapper.set(property, result);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy