diff options
author | 2021-08-03 18:42:39 +0900 | |
---|---|---|
committer | 2021-08-06 19:32:38 +0900 | |
commit | be4f78978faba3d3ceb88df02a7f93a2e09ff1e0 (patch) | |
tree | 1f3f1a96251ac4f655c8a96fc33d5d4ee779cd06 /rba.tool.core/src/rba/tool/core/sort/ComparisonAndEvaluator.java | |
parent | 71ca7c6cab863767ef30c8bd05b2bbfda8731cb5 (diff) |
Initial commit
Bug-AGL: SPEC-4033
Signed-off-by: Kenji Hosokawa <khosokawa@jp.adit-jv.com>
Diffstat (limited to 'rba.tool.core/src/rba/tool/core/sort/ComparisonAndEvaluator.java')
-rw-r--r-- | rba.tool.core/src/rba/tool/core/sort/ComparisonAndEvaluator.java | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/rba.tool.core/src/rba/tool/core/sort/ComparisonAndEvaluator.java b/rba.tool.core/src/rba/tool/core/sort/ComparisonAndEvaluator.java new file mode 100644 index 0000000..5a4b1b2 --- /dev/null +++ b/rba.tool.core/src/rba/tool/core/sort/ComparisonAndEvaluator.java @@ -0,0 +1,49 @@ +package rba.tool.core.sort; + +import org.eclipse.emf.common.util.EList; + +import rba.core.ComparisonAnd; +import rba.core.ComparisonOperator; +import rba.core.Expression; +import rba.core.GreaterThanOperator; +import rba.core.LetStatement; +import rba.core.MuchGreaterThanOperator; +import rba.core.RuleObject; + +public class ComparisonAndEvaluator<T extends RuleObject> extends ComparisonOperatorEvaluator<T> implements ComparisonAnd { + + public ComparisonAndEvaluator(ComparisonAnd o) { + super(o); + } + + @Override + public boolean evaluate(ValueSortedList<T> list) { + // TODO Auto-generated method stub + return false; + } + + @Override + public int suggestIndex(ValueSortedList<T> list) { + int max = 9999; + int min = -1; + + for (Expression operand : operator.getOperand()) { + if (operand instanceof GreaterThanOperator || operand instanceof MuchGreaterThanOperator) { + int i = list.createEvaluator((ComparisonOperator) operand).suggestIndex(list); + if (i > min && i >= 0) { + min = i; + } + } else { + throw new RuntimeException("Unsupported expression [" + operator.getExpression() + "]"); + } + } + return Math.min(min, max); + } + + @Override + public EList<LetStatement> getLetStatements() { + // TODO Auto-generated method stub + return null; + } + +} |