Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.osee.ote.core/src/org/eclipse/osee/ote/message/condition/ComparisonCondition.java')
-rw-r--r--org.eclipse.osee.ote.core/src/org/eclipse/osee/ote/message/condition/ComparisonCondition.java55
1 files changed, 55 insertions, 0 deletions
diff --git a/org.eclipse.osee.ote.core/src/org/eclipse/osee/ote/message/condition/ComparisonCondition.java b/org.eclipse.osee.ote.core/src/org/eclipse/osee/ote/message/condition/ComparisonCondition.java
new file mode 100644
index 000000000..89b7b0cd5
--- /dev/null
+++ b/org.eclipse.osee.ote.core/src/org/eclipse/osee/ote/message/condition/ComparisonCondition.java
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.ote.message.condition;
+
+import org.eclipse.osee.ote.message.elements.DiscreteElement;
+
+/**
+ * @author Ken J. Aguilar
+ */
+
+public class ComparisonCondition<T extends Comparable<T>> extends AbstractCondition implements IDiscreteElementCondition<T> {
+
+ private final DiscreteElement<T> element;
+ private final T value;
+ private final EqualityOperation operation;
+ private T lastValue = null;
+
+ public ComparisonCondition(DiscreteElement<T> element, EqualityOperation operation, T value) {
+ this.element = element;
+ this.operation = operation;
+ this.value = value;
+ }
+
+ @Override
+ public T getLastCheckValue() {
+ return lastValue;
+ }
+
+ @Override
+ public boolean check() {
+ lastValue = element.getValue();
+ return operation.evaluate(lastValue, value);
+ }
+
+ public DiscreteElement<T> getElement() {
+ return element;
+ }
+
+ public T getValue() {
+ return value;
+ }
+
+ public EqualityOperation getOperation() {
+ return operation;
+ }
+
+}

Back to the top