/
AllKnownEEsResolutionHints.java
83 lines (70 loc) · 2.7 KB
/
AllKnownEEsResolutionHints.java
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
/*******************************************************************************
* Copyright (c) 2014 SAP SE and others.
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* SAP SE - initial API and implementation
*******************************************************************************/
package org.eclipse.tycho.p2.target.ee;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Objects;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.metadata.IRequirement;
import org.eclipse.equinox.p2.metadata.VersionedId;
import org.eclipse.tycho.core.ee.shared.ExecutionEnvironment;
import org.eclipse.tycho.p2.util.resolution.ExecutionEnvironmentResolutionHints;
public class AllKnownEEsResolutionHints implements ExecutionEnvironmentResolutionHints {
private final Map<VersionedId, IInstallableUnit> temporaryUnits;
public AllKnownEEsResolutionHints(Collection<ExecutionEnvironment> allKnownEEs) {
temporaryUnits = new LinkedHashMap<>();
for (ExecutionEnvironment ee : allKnownEEs) {
StandardEEResolutionHints.addIUsFromEnvironment(ee, temporaryUnits);
}
}
@Override
public Collection<IInstallableUnit> getMandatoryUnits() {
return Collections.emptyList();
}
@Override
public boolean isNonApplicableEEUnit(IInstallableUnit iu) {
// See JREAction
return iu.getId().startsWith("a.jre") || iu.getId().startsWith("config.a.jre");
}
@Override
public boolean isEESpecificationUnit(IInstallableUnit unit) {
// not needed
throw new UnsupportedOperationException();
}
@Override
public Collection<IRequirement> getMandatoryRequires() {
// not needed; getMandatoryUnits already enforces the use of the JRE IUs during resolution
return Collections.emptyList();
}
@Override
public Collection<IInstallableUnit> getTemporaryAdditions() {
return temporaryUnits.values();
}
@Override
public int hashCode() {
return Objects.hash(temporaryUnits);
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
AllKnownEEsResolutionHints other = (AllKnownEEsResolutionHints) obj;
return Objects.equals(temporaryUnits, other.temporaryUnits);
}
}