Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/helpers/CollectionUtils.java18
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/CoercingComparator.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/MatchExpression.java3
3 files changed, 21 insertions, 2 deletions
diff --git a/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/helpers/CollectionUtils.java b/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/helpers/CollectionUtils.java
index e6da80ea5..5bea8c961 100644
--- a/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/helpers/CollectionUtils.java
+++ b/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/helpers/CollectionUtils.java
@@ -148,6 +148,24 @@ public class CollectionUtils {
}
/**
+ * Creates a combined hash for an array of objects.
+ * @param objects The objects to hash
+ * @return The combined hashCode of the objects.
+ */
+ public static int hashCode(Object objects[]) {
+ if (objects == null)
+ return 0;
+
+ int result = 1;
+ int idx = objects.length;
+ while (--idx >= 0) {
+ Object object = objects[idx];
+ result = 17 * result + (object == null ? 0 : object.hashCode());
+ }
+ return result;
+ }
+
+ /**
* The emptyList() method was introduced in Java 1.5 so we need this here to be able to
* down compile to 1.4.
* @param <T> The type of the elements
diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/CoercingComparator.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/CoercingComparator.java
index fde3c4eee..c69e75e32 100644
--- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/CoercingComparator.java
+++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/CoercingComparator.java
@@ -25,7 +25,7 @@ import org.eclipse.equinox.p2.metadata.Version;
public abstract class CoercingComparator<T> {
static class BooleanCoercer extends CoercingComparator<Boolean> {
public int compare(Boolean o1, Boolean o2) {
- return o1.compareTo(o2);
+ return o1.booleanValue() == o2.booleanValue() ? 0 : (o1.booleanValue() ? 1 : -1);
}
@Override
diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/MatchExpression.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/MatchExpression.java
index eb5cc7705..efb636bb9 100644
--- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/MatchExpression.java
+++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/MatchExpression.java
@@ -11,6 +11,7 @@
package org.eclipse.equinox.internal.p2.metadata.expression;
import java.util.Arrays;
+import org.eclipse.equinox.internal.p2.core.helpers.CollectionUtils;
import org.eclipse.equinox.p2.metadata.expression.*;
/**
@@ -60,7 +61,7 @@ class MatchExpression<T> extends Unary implements IMatchExpression<T> {
}
public int hashCode() {
- return operand.hashCode() * 31 + Arrays.hashCode(parameters);
+ return operand.hashCode() * 31 + CollectionUtils.hashCode(parameters);
}
public boolean isMatch(IEvaluationContext context, T value) {

Back to the top