
com.nedap.archie.rules.evaluation.evaluators.ConstantEvaluator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of tools Show documentation
Show all versions of tools Show documentation
tools that operate on the archie reference models and archetype object model
The newest version!
package com.nedap.archie.rules.evaluation.evaluators;
import com.google.common.collect.Lists;
import com.nedap.archie.rules.Constant;
import com.nedap.archie.rules.PrimitiveType;
import com.nedap.archie.rules.evaluation.Evaluator;
import com.nedap.archie.rules.evaluation.RuleEvaluation;
import com.nedap.archie.rules.evaluation.ValueList;
import java.util.List;
/**
* Created by pieter.bos on 01/04/16.
*/
public class ConstantEvaluator implements Evaluator> {
@Override
public ValueList evaluate(RuleEvaluation> evaluation, Constant> statement) {
return new ValueList(convertNumber(statement.getValue()), PrimitiveType.fromExpressionType(statement.getType()));
}
private Object convertNumber(Object value) {
if(value instanceof Integer) {
return ((Integer) value).longValue();
} else if(value instanceof Float) {
return ((Float) value).doubleValue();
}
return value;
}
@Override
public List> getSupportedClasses() {
return Lists.newArrayList(Constant.class);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy