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_/CriterionIntPredicate.java')
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/predicate/int_/CriterionIntPredicate.java71
1 files changed, 71 insertions, 0 deletions
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/predicate/int_/CriterionIntPredicate.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/predicate/int_/CriterionIntPredicate.java
new file mode 100644
index 0000000000..d895490a86
--- /dev/null
+++ b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/predicate/int_/CriterionIntPredicate.java
@@ -0,0 +1,71 @@
+/*******************************************************************************
+ * 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.internal.ObjectTools;
+import org.eclipse.jpt.common.utility.predicate.IntPredicate;
+
+/**
+ * Simple, abstract implementation of {@link IntPredicate}
+ * that holds on to a criterion object that can be used in the
+ * {@link #evaluate(int) evaluate} method.
+ * <p>
+ * This class simplifies the implementation of straightforward inner classes.
+ *
+ * @param <C> the type of the filter's criterion
+ */
+public abstract class CriterionIntPredicate<C>
+ implements IntPredicate
+{
+ protected final C criterion;
+
+
+ /**
+ * Construct a simple predicate with a <code>null</code> criterion.
+ */
+ protected CriterionIntPredicate() {
+ this(null);
+ }
+
+ /**
+ * More useful constructor. The specified criterion can
+ * be used by a subclass to evaluate objects.
+ */
+ protected CriterionIntPredicate(C criterion) {
+ super();
+ this.criterion = criterion;
+ }
+
+ /**
+ * Return the predicate's criterion.
+ */
+ public C getCriterion() {
+ return this.criterion;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (o.getClass() != this.getClass()) {
+ return false;
+ }
+ CriterionIntPredicate<?> other = (CriterionIntPredicate<?>) o;
+ return ObjectTools.equals(this.criterion, other.criterion);
+ }
+
+ @Override
+ public int hashCode() {
+ return (this.criterion == null) ? 0 : this.criterion.hashCode();
+ }
+
+ @Override
+ public String toString() {
+ return ObjectTools.toString(this, this.criterion);
+ }
+}

Back to the top