1 package org
.argeo
.osgi
.a2
;
3 import java
.util
.Collections
;
5 import java
.util
.TreeMap
;
8 * A category grouping a set of {@link A2Component}, typically based on the
9 * provider of these components. This is the equivalent of Maven's group Id.
11 public class A2Contribution
implements Comparable
<A2Contribution
> {
12 final static String BOOT
= "boot";
13 final static String RUNTIME
= "runtime";
14 final static String CLASSPATH
= "classpath";
16 private final ProvisioningSource source
;
17 private final String id
;
19 final Map
<String
, A2Component
> components
= Collections
.synchronizedSortedMap(new TreeMap
<>());
22 * The contribution must be added to the source. Rather use
23 * {@link AbstractProvisioningSource#getOrAddContribution(String)} than this
24 * contructor directly.
26 public A2Contribution(ProvisioningSource context
, String id
) {
27 this.source
= context
;
29 // if (context != null)
30 // context.contributions.put(id, this);
33 A2Component
getOrAddComponent(String componentId
) {
34 if (components
.containsKey(componentId
))
35 return components
.get(componentId
);
37 return new A2Component(this, componentId
);
40 public ProvisioningSource
getSource() {
44 public String
getId() {
49 public int compareTo(A2Contribution o
) {
50 return id
.compareTo(o
.id
);
54 public int hashCode() {
59 public boolean equals(Object obj
) {
60 if (obj
instanceof A2Contribution
) {
61 A2Contribution o
= (A2Contribution
) obj
;
62 return id
.equals(o
.id
);
68 public String
toString() {
72 void asTree(String prefix
, StringBuffer buf
) {
75 for (String componentId
: components
.keySet()) {
77 buf
.append(componentId
);
78 A2Component component
= components
.get(componentId
);
79 component
.asTree(prefix
, buf
);