Skip to main content
summaryrefslogtreecommitdiffstats
blob: f6dfac89e5fec5170e93cc0b60f493f790ba9ae1 (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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/*******************************************************************************
 * 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
 *   IBM - ongoing development
 ******************************************************************************/
package org.eclipse.equinox.p2.publisher;

import java.util.*;
import org.eclipse.equinox.p2.metadata.Version;
import org.eclipse.equinox.p2.repository.artifact.IArtifactRepository;
import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository;

public class PublisherInfo implements IPublisherInfo {

	private int artifactOptions = 0;
	private IMetadataRepository metadataRepository;
	private IArtifactRepository artifactRepository;
	private IMetadataRepository contextMetadataRepository;
	private IArtifactRepository contextArtifactRepository;
	private String[] configurations = new String[0];
	private List<IPublisherAdvice> adviceList = new ArrayList<>(11);

	@Override
	public void addAdvice(IPublisherAdvice advice) {
		adviceList.add(advice);
	}

	public List<IPublisherAdvice> getAdvice() {
		return adviceList;
	}

	@Override
	@SuppressWarnings("unchecked")
	public <T extends IPublisherAdvice> Collection<T> getAdvice(String configSpec, boolean includeDefault, String id, Version version, Class<T> type) {
		ArrayList<T> result = new ArrayList<>();
		for (IPublisherAdvice advice : adviceList) {
			if (type.isInstance(advice) && advice.isApplicable(configSpec, includeDefault, id, version))
				// Ideally, we would use Class.cast here but it was introduced in Java 1.5
				result.add((T) advice);
		}
		return result;
	}

	@Override
	public IArtifactRepository getArtifactRepository() {
		return artifactRepository;
	}

	@Override
	public IMetadataRepository getMetadataRepository() {
		return metadataRepository;
	}

	@Override
	public IArtifactRepository getContextArtifactRepository() {
		return contextArtifactRepository;
	}

	@Override
	public IMetadataRepository getContextMetadataRepository() {
		return contextMetadataRepository;
	}

	@Override
	public int getArtifactOptions() {
		return artifactOptions;
	}

	public void setArtifactRepository(IArtifactRepository value) {
		artifactRepository = value;
	}

	public void setMetadataRepository(IMetadataRepository value) {
		metadataRepository = value;
	}

	public void setContextArtifactRepository(IArtifactRepository value) {
		contextArtifactRepository = value;
	}

	public void setContextMetadataRepository(IMetadataRepository value) {
		contextMetadataRepository = value;
	}

	public void setArtifactOptions(int value) {
		artifactOptions = value;
	}

	@Override
	public String[] getConfigurations() {
		return configurations;
	}

	public void setConfigurations(String[] value) {
		configurations = value;
	}

	public String getSummary() {
		return "."; //$NON-NLS-1$
	}

}

Back to the top