Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Arthorne2010-01-14 17:04:57 +0000
committerJohn Arthorne2010-01-14 17:04:57 +0000
commit76baf1fce9ca194e1c921b3785529608ec2fd1de (patch)
treeaaac5b20f9cbe925056a0ff7db755eeaea860249
parent07823255fadb012b803e818e2bcb9af008f337d2 (diff)
downloadrt.equinox.p2-76baf1fce9ca194e1c921b3785529608ec2fd1de.tar.gz
rt.equinox.p2-76baf1fce9ca194e1c921b3785529608ec2fd1de.tar.xz
rt.equinox.p2-76baf1fce9ca194e1c921b3785529608ec2fd1de.zip
Bug 299562 - Use varargs for CompoundQueryable and PipedQuery
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/query/CompoundQueryable.java36
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/query/PipedQuery.java15
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/core/CompoundQueryableTest.java8
3 files changed, 47 insertions, 12 deletions
diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/query/CompoundQueryable.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/query/CompoundQueryable.java
index 9c1e8d6b9..df0b87907 100644
--- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/query/CompoundQueryable.java
+++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/query/CompoundQueryable.java
@@ -6,7 +6,6 @@
*
* Contributors:
* EclipseSource - initial API and implementation
-* IBM Corporation - ongoing development
******************************************************************************/
package org.eclipse.equinox.p2.query;
@@ -24,20 +23,43 @@ public class CompoundQueryable<T> implements IQueryable<T> {
private IQueryable<T>[] queryables;
- /**
- * Creates a queryable that combines the provided input queryables
- *
- * @param queryables The queryables that comprise this compound queryable
- */
- public CompoundQueryable(IQueryable<T>... queryables) {
+ private CompoundQueryable(IQueryable<T>[] queryables) {
this.queryables = queryables;
}
+ /**
+ * Creates a queryable that combines the given collection of input queryables
+ *
+ * @param queryables The collection of queryables to be combined
+ */
@SuppressWarnings("unchecked")
public CompoundQueryable(Collection<? extends IQueryable<T>> queryables) {
this(queryables.toArray(new IQueryable[queryables.size()]));
}
+ /**
+ * Creates a queryable that combines the two provided input queryables
+ *
+ * @param query1 The first queryable
+ * @param query2 The second queryable
+ */
+ @SuppressWarnings("unchecked")
+ public CompoundQueryable(IQueryable<T> query1, IQueryable<T> query2) {
+ this(new IQueryable[] {query1, query2});
+ }
+
+ /**
+ * Creates a queryable that combines the three provided input queryables
+ *
+ * @param query1 The first queryable
+ * @param query2 The second queryable
+ * @param query3 The third queryable
+ */
+ @SuppressWarnings("unchecked")
+ public CompoundQueryable(IQueryable<T> query1, IQueryable<T> query2, IQueryable<T> query3) {
+ this(new IQueryable[] {query1, query2, query3});
+ }
+
/* (non-Javadoc)
* @see org.eclipse.equinox.p2.query.IQueryable#query(org.eclipse.equinox.p2.query.IQuery, org.eclipse.core.runtime.IProgressMonitor)
*/
diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/query/PipedQuery.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/query/PipedQuery.java
index f87987c61..2720f6a8f 100644
--- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/query/PipedQuery.java
+++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/query/PipedQuery.java
@@ -29,10 +29,23 @@ public class PipedQuery<T> implements ICompositeQuery<T> {
*
* @param queries the ordered list of queries to perform
*/
- public PipedQuery(IQuery<T>... queries) {
+ public PipedQuery(IQuery<T>[] queries) {
this.queries = queries;
}
+ /**
+ * Creates a piped query based on the two provided input queries. The full
+ * query input will be passed into the first query in the provided array. The
+ * second query will obtain as input the result of the first query.
+ *
+ * @param query1 the first query
+ * @param query2 the second query
+ */
+ @SuppressWarnings("unchecked")
+ public PipedQuery(IQuery<T> query1, IQuery<T> query2) {
+ this(new IQuery[] {query1, query2});
+ }
+
/*(non-Javadoc)
* @see org.eclipse.equinox.p2.query.IQuery#getId()
*/
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/core/CompoundQueryableTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/core/CompoundQueryableTest.java
index c05dd804a..0b324cac8 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/core/CompoundQueryableTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/core/CompoundQueryableTest.java
@@ -171,7 +171,7 @@ public class CompoundQueryableTest extends TestCase {
}
public void testSingleQueryable() {
- CompoundQueryable cQueryable = new CompoundQueryable(queryable1);
+ CompoundQueryable cQueryable = new CompoundQueryable(Arrays.asList(queryable1));
CompoundQueryTestProgressMonitor monitor = new CompoundQueryTestProgressMonitor();
IQueryResult queryResult = cQueryable.query(matchQuery, monitor);
assertEquals("1.0", 2, AbstractProvisioningTest.queryResultSize(queryResult));
@@ -180,7 +180,7 @@ public class CompoundQueryableTest extends TestCase {
}
public void testSingleContextQuery() {
- CompoundQueryable cQueryable = new CompoundQueryable(queryable1);
+ CompoundQueryable cQueryable = new CompoundQueryable(Arrays.asList(queryable1));
CompoundQueryTestProgressMonitor monitor = new CompoundQueryTestProgressMonitor();
IQueryResult queryResult = cQueryable.query(greatestNumberQuery, monitor);
assertEquals("1.0", 1, AbstractProvisioningTest.queryResultSize(queryResult));
@@ -227,7 +227,7 @@ public class CompoundQueryableTest extends TestCase {
}
public void testSingleQueryableProgressMonitor() {
- CompoundQueryable cQueryable = new CompoundQueryable(queryable1);
+ CompoundQueryable cQueryable = new CompoundQueryable(Arrays.asList(queryable1));
CompoundQueryTestProgressMonitor monitor = new CompoundQueryTestProgressMonitor();
cQueryable.query(matchQuery, monitor);
assertTrue("1.0", monitor.isDone());
@@ -235,7 +235,7 @@ public class CompoundQueryableTest extends TestCase {
}
public void testSingleContextQueryProgressMonitor() {
- CompoundQueryable cQueryable = new CompoundQueryable(queryable1);
+ CompoundQueryable cQueryable = new CompoundQueryable(Arrays.asList(queryable1));
CompoundQueryTestProgressMonitor monitor = new CompoundQueryTestProgressMonitor();
cQueryable.query(greatestNumberQuery, monitor);
assertTrue("1.0", monitor.isDone());

Back to the top