package foundation.code;
|
|
import java.util.List;
|
|
import foundation.data.entity.Entity;
|
import foundation.variant.expression.Segment;
|
import foundation.variant.expression.VariantExpression;
|
|
public class CodeRule {
|
|
public static String Param_DynamicSegment = "dynamic_segment";
|
private String id;
|
private String code;
|
private String name;
|
private String rule;
|
private VariantExpression expression;
|
|
public CodeRule() {
|
|
}
|
|
public void load(Entity entity) throws Exception {
|
id = entity.getString("id");
|
code = entity.getString("code");
|
name = entity.getString("name");
|
rule = entity.getString("rule");
|
|
expression = new VariantExpression(rule);
|
}
|
|
public CodeRuleRuntime toRuntime() {
|
CodeRuleRuntime result = new CodeRuleRuntime(this);
|
|
List<Segment> segments = expression.getSegments();
|
|
for (Segment segment: segments) {
|
SegmentCreator creator = SegmentCreator.getInstance(this, segment);
|
|
if (creator == null) {
|
continue;
|
}
|
|
result.add(creator);
|
}
|
|
return result;
|
}
|
|
public String getId() {
|
return id;
|
}
|
|
public String getName() {
|
return name;
|
}
|
|
public String getCode() {
|
return code;
|
}
|
|
public String getRule() {
|
return rule;
|
}
|
|
public void setRule(String rule) throws Exception {
|
this.rule = rule;
|
expression = new VariantExpression(rule);
|
}
|
|
}
|