| 1 |
/******************************************************************************* |
| 2 |
* Copyright (c) 2008, 2017 Code 9 and others. |
| 3 |
* |
| 4 |
* This |
| 5 |
* program and the accompanying materials are made available under the terms of |
| 6 |
* the Eclipse Public License 2.0 which accompanies this distribution, and is |
| 7 |
* available at |
| 8 |
* https://www.eclipse.org/legal/epl-2.0/ |
| 9 |
* |
| 10 |
* SPDX-License-Identifier: EPL-2.0 |
| 11 |
* |
| 12 |
* Contributors: |
| 13 |
* Code 9 - initial API and implementation |
| 14 |
* IBM - ongoing development |
| 15 |
******************************************************************************/ |
| 16 |
package org.eclipse.equinox.p2.publisher; |
| 17 |
|
| 18 |
import java.util.*; |
| 19 |
import org.eclipse.equinox.p2.metadata.Version; |
| 20 |
import org.eclipse.equinox.p2.repository.artifact.IArtifactRepository; |
| 21 |
import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository; |
| 22 |
|
| 23 |
public class PublisherInfo implements IPublisherInfo { |
| 24 |
|
| 25 |
private int artifactOptions = 0; |
| 26 |
private IMetadataRepository metadataRepository; |
| 27 |
private IArtifactRepository artifactRepository; |
| 28 |
private IMetadataRepository contextMetadataRepository; |
| 29 |
private IArtifactRepository contextArtifactRepository; |
| 30 |
private String[] configurations = new String[0]; |
| 31 |
private List<IPublisherAdvice> adviceList = new ArrayList<>(11); |
| 32 |
|
| 33 |
@Override |
| 34 |
public void addAdvice(IPublisherAdvice advice) { |
| 35 |
adviceList.add(advice); |
| 36 |
} |
| 37 |
|
| 38 |
public List<IPublisherAdvice> getAdvice() { |
| 39 |
return adviceList; |
| 40 |
} |
| 41 |
|
| 42 |
@Override |
| 43 |
@SuppressWarnings("unchecked") |
| 44 |
public <T extends IPublisherAdvice> Collection<T> getAdvice(String configSpec, boolean includeDefault, String id, Version version, Class<T> type) { |
| 45 |
ArrayList<T> result = new ArrayList<>(); |
| 46 |
for (IPublisherAdvice advice : adviceList) { |
| 47 |
if (type.isInstance(advice) && advice.isApplicable(configSpec, includeDefault, id, version)) |
| 48 |
// Ideally, we would use Class.cast here but it was introduced in Java 1.5 |
| 49 |
result.add((T) advice); |
| 50 |
} |
| 51 |
return result; |
| 52 |
} |
| 53 |
|
| 54 |
@Override |
| 55 |
public IArtifactRepository getArtifactRepository() { |
| 56 |
return artifactRepository; |
| 57 |
} |
| 58 |
|
| 59 |
@Override |
| 60 |
public IMetadataRepository getMetadataRepository() { |
| 61 |
return metadataRepository; |
| 62 |
} |
| 63 |
|
| 64 |
@Override |
| 65 |
public IArtifactRepository getContextArtifactRepository() { |
| 66 |
return contextArtifactRepository; |
| 67 |
} |
| 68 |
|
| 69 |
@Override |
| 70 |
public IMetadataRepository getContextMetadataRepository() { |
| 71 |
return contextMetadataRepository; |
| 72 |
} |
| 73 |
|
| 74 |
@Override |
| 75 |
public int getArtifactOptions() { |
| 76 |
return artifactOptions; |
| 77 |
} |
| 78 |
|
| 79 |
public void setArtifactRepository(IArtifactRepository value) { |
| 80 |
artifactRepository = value; |
| 81 |
} |
| 82 |
|
| 83 |
public void setMetadataRepository(IMetadataRepository value) { |
| 84 |
metadataRepository = value; |
| 85 |
} |
| 86 |
|
| 87 |
public void setContextArtifactRepository(IArtifactRepository value) { |
| 88 |
contextArtifactRepository = value; |
| 89 |
} |
| 90 |
|
| 91 |
public void setContextMetadataRepository(IMetadataRepository value) { |
| 92 |
contextMetadataRepository = value; |
| 93 |
} |
| 94 |
|
| 95 |
public void setArtifactOptions(int value) { |
| 96 |
artifactOptions = value; |
| 97 |
} |
| 98 |
|
| 99 |
@Override |
| 100 |
public String[] getConfigurations() { |
| 101 |
return configurations; |
| 102 |
} |
| 103 |
|
| 104 |
public void setConfigurations(String[] value) { |
| 105 |
configurations = value; |
| 106 |
} |
| 107 |
|
| 108 |
public String getSummary() { |
| 109 |
return "."; //$NON-NLS-1$ |
| 110 |
} |
| 111 |
|
| 112 |
} |