Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/predicate/int_/OR.java')
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/predicate/int_/OR.java51
1 files changed, 51 insertions, 0 deletions
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/predicate/int_/OR.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/predicate/int_/OR.java
new file mode 100644
index 0000000000..9340e6403c
--- /dev/null
+++ b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/predicate/int_/OR.java
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2015 Oracle. 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:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.common.utility.internal.predicate.int_;
+
+import org.eclipse.jpt.common.utility.predicate.IntPredicate;
+
+/**
+ * This compound predicate will evaluate to <code>true</code> if <em>any</em>
+ * its wrapped predicates evaluates to <code>true</code>.
+ * If there are <em>no</em> wrapped
+ * predicates, this predicate will always evaluate to <code>false</code>.
+ * If there are wrapped predicates, this predicate will
+ * exhibit "short-circuit" behavior; i.e. if any wrapped predicate evaluates
+ * to <code>true</code>, no following wrapped predicates will be evaluated.
+ *
+ * @see AND
+ * @see XOR
+ * @see NOT
+ */
+public class OR
+ extends AbstractCompoundIntPredicate
+{
+ /**
+ * Construct a predicate that will evaluate to <code>true</code> if <em>any</em>
+ * the specified predicates evaluates to <code>true</code>.
+ */
+ public OR(IntPredicate... predicates) {
+ super(predicates);
+ }
+
+ public boolean evaluate(int variable) {
+ for (IntPredicate predicate : this.predicates) {
+ if (predicate.evaluate(variable)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ @Override
+ protected String operatorString() {
+ return "OR"; //$NON-NLS-1$
+ }
+}

Back to the top