com.app.common.utils.ExecSeqManager Maven / Gradle / Ivy
The newest version!
package com.app.common.utils;
import org.springframework.stereotype.Component;
import java.util.Hashtable;
import java.util.Map.Entry;
/**
* 成交序号管理
*
* @author deshuai.kong
*
*/
@Component
public class ExecSeqManager {
static Hashtable ht = new Hashtable();
static String defaultSeqName = "default";
public static void addExecSeq(String seqName) {
ht.put(seqName, new ExecSeq());
}
public static ExecSeq getExecSeq(String seqName) {
ExecSeq es = ht.get(seqName);
if (es == null) {
addExecSeq(seqName);
}
es = ht.get(seqName);
return es;
}
static {
addExecSeq(defaultSeqName);
}
public static int getCurrentSeq() {
return getCurrentSeq(defaultSeqName);
}
public static int getSeq() {
return getSeq(defaultSeqName);
}
public static void set(int value) {
set(defaultSeqName, value);
}
public static void clear() {
for (Entry entry : ht.entrySet()) {
entry.getValue().set(0);
}
}
public static int getCurrentSeq(String seqName) {
return getExecSeq(seqName).getCurrentSeq();
}
public static int getSeq(String seqName) {
return getExecSeq(seqName).getSeq();
}
public static void set(String seqName, int value) {
getExecSeq(seqName).set(value);
}
public static void clear(String seqName) {
getExecSeq(seqName).set(0);
}
}