package com.engine.salary.formlua.entity.parameter;

import com.alibaba.fastjson.JSONObject;


public class FormulaContext {
	public static ThreadLocal<FormulaContext> fmCtx=new ThreadLocal<FormulaContext>();

	private JSONObject formulaJson=new JSONObject();

	public static FormulaContext get(){
		if(null==fmCtx.get()){
			fmCtx.set(new FormulaContext());
		}
		return fmCtx.get();
	}

	public JSONObject getFormulaJson() {
		return formulaJson;
	}
	public void setValue(String func){
		if(formulaJson.getInteger(func)!=null){
			int i=formulaJson.getInteger(func)+1;
			formulaJson.put(func,i);
		}else {
			formulaJson.put(func,1);
		}
	}
	public Integer getValue(String func){
		return formulaJson.getInteger(func);
	}
	public void removeContext(){
		fmCtx.remove();
	}
}