package extend.pk;

import com.taurus.core.entity.ITObject;
import com.taurus.core.entity.TObject;

import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;

public class SettleLog {
	private Map<String,Integer>		log;
	
	public SettleLog() {
		log = new HashMap<String,Integer>();
	}
	
	public void put(String key,Integer value) {
		log.put(key, value);
	}
	
	public void add(String key) {
		if(!log.containsKey(key)) {
			return;
		}
		int value = log.get(key);
		value++;
		log.put(key, value);
	}
	
	public Integer get(String key) {
		if(!log.containsKey(key)) {
			return null;
		}
		return log.get(key);
	}
	
	public ITObject toTObject() {
		ITObject obj = TObject.newInstance();
		for (Entry<String, Integer> entry : this.log.entrySet()) {
			obj.putInt(entry.getKey(), entry.getValue());
		}
		return obj;
	}
}
