1 package org
.argeo
.init
.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 public Iterable
<A2Component
> listComponents(Object filter
) {
34 return components
.values();
37 A2Component
getOrAddComponent(String componentId
) {
38 if (components
.containsKey(componentId
))
39 return components
.get(componentId
);
41 return new A2Component(this, componentId
);
44 public ProvisioningSource
getSource() {
48 public String
getId() {
53 public int compareTo(A2Contribution o
) {
54 return id
.compareTo(o
.id
);
58 public int hashCode() {
63 public boolean equals(Object obj
) {
64 if (obj
instanceof A2Contribution
) {
65 A2Contribution o
= (A2Contribution
) obj
;
66 return id
.equals(o
.id
);
72 public String
toString() {
76 void asTree(String prefix
, StringBuffer buf
) {
79 for (String componentId
: components
.keySet()) {
81 buf
.append(componentId
);
82 A2Component component
= components
.get(componentId
);
83 component
.asTree(prefix
, buf
);