Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 7462b17e9a168cafad62b00f0da6d45387a387c5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/*******************************************************************************
 * Copyright (c) 2008, 2017 Code 9 and others.
 * 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: 
 *   Code 9 - initial API and implementation
 ******************************************************************************/
package org.eclipse.equinox.p2.publisher.actions;

import java.util.Arrays;
import java.util.Collection;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.publisher.AbstractAdvice;
import org.eclipse.equinox.p2.publisher.IPublisherResult;
import org.eclipse.equinox.p2.query.IQuery;

public class RootIUResultFilterAdvice extends AbstractAdvice implements IRootIUAdvice {
	private IQuery<IInstallableUnit> query;

	public RootIUResultFilterAdvice(IQuery<IInstallableUnit> query) {
		this.query = query;
	}

	@Override
	public Collection<IInstallableUnit> getChildren(IPublisherResult result) {
		Collection<IInstallableUnit> value = result.getIUs(null, IPublisherResult.ROOT);
		if (query == null)
			return value;
		return Arrays.asList(query.perform(value.iterator()).toArray(IInstallableUnit.class));
	}
}

Back to the top