/*
* This code is ugly because JSR-175 does not allow null values, thus we are
* forced to use sentinal values.
*/
private RuleMetadata createRuleMetadataFromNamedValues(Class pojoClass, Rule ruleAnnotation) {
BasicRuleMetadata metadata = new BasicRuleMetadata();
if (ruleAnnotation.name().length() > 0) {
metadata.setName(ruleAnnotation.name());
} else {
metadata.setName(pojoClass.getName());
}
if (ruleAnnotation.documentation().length() > 0) {
metadata.setDocumentation(ruleAnnotation.documentation());
}
if (ruleAnnotation.salience() != Integer.MIN_VALUE) {
metadata.setSalience(ruleAnnotation.salience());
}
if (ruleAnnotation.duration() != Long.MIN_VALUE) {
metadata.setDuration(ruleAnnotation.duration());
}
if (ruleAnnotation.loop() != Rule.Loop.DEFAULT) {
metadata.setNoLoop(ruleAnnotation.loop().getValue());
}
return metadata;
}