package foundation.code;
|
|
import java.util.ArrayList;
|
import java.util.List;
|
|
import foundation.variant.provider.IVariantsProvider;
|
|
public class CodeRuleRuntime {
|
|
private CodeRule codeRule;
|
private List<SegmentCreator> creatorList;
|
|
|
public CodeRuleRuntime(CodeRule codeRule) {
|
creatorList = new ArrayList<SegmentCreator>();
|
this.codeRule = codeRule;
|
}
|
|
public String nextval(String dynamic, IVariantsProvider... entitys) {
|
synchronized (this) {
|
StringBuilder result = new StringBuilder();
|
|
for (SegmentCreator creator: creatorList) {
|
String value = creator.getNextSequenceValue(dynamic, entitys);
|
result.append(value);
|
}
|
|
return result.toString();
|
}
|
}
|
|
public String currval(String dynamic, IVariantsProvider... entitys) {
|
synchronized (this) {
|
StringBuilder result = new StringBuilder();
|
|
for (SegmentCreator creator: creatorList) {
|
String value = creator.getNextSequenceValue(dynamic, entitys);
|
result.append(value);
|
}
|
|
return result.toString();
|
}
|
}
|
|
public String tempval(String dynamic, IVariantsProvider... entitys) {
|
synchronized (this) {
|
StringBuilder result = new StringBuilder();
|
|
for (SegmentCreator creator: creatorList) {
|
String value = creator.getTempValue(dynamic, entitys);
|
result.append(value);
|
}
|
|
return result.toString();
|
}
|
}
|
|
public String getCode() {
|
return codeRule.getCode();
|
}
|
|
public void add(SegmentCreator creator) {
|
if (creator == null) {
|
return;
|
}
|
|
creatorList.add(creator);
|
}
|
|
}
|