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 final static String DEFAULT
= "default";
18 private final ProvisioningSource source
;
19 private final String id
;
21 final Map
<String
, A2Component
> components
= Collections
.synchronizedSortedMap(new TreeMap
<>());
24 * The contribution must be added to the source. Rather use
25 * {@link AbstractProvisioningSource#getOrAddContribution(String)} than this
26 * contructor directly.
28 public A2Contribution(ProvisioningSource context
, String id
) {
29 this.source
= context
;
31 // if (context != null)
32 // context.contributions.put(id, this);
35 public Iterable
<A2Component
> listComponents(Object filter
) {
36 return components
.values();
39 A2Component
getOrAddComponent(String componentId
) {
40 if (components
.containsKey(componentId
))
41 return components
.get(componentId
);
43 return new A2Component(this, componentId
);
46 public ProvisioningSource
getSource() {
50 public String
getId() {
55 public int compareTo(A2Contribution o
) {
56 return id
.compareTo(o
.id
);
60 public int hashCode() {
65 public boolean equals(Object obj
) {
66 if (obj
instanceof A2Contribution
) {
67 A2Contribution o
= (A2Contribution
) obj
;
68 return id
.equals(o
.id
);
74 public String
toString() {
78 void asTree(String prefix
, StringBuffer buf
) {
81 for (String componentId
: components
.keySet()) {
83 buf
.append(componentId
);
84 A2Component component
= components
.get(componentId
);
85 component
.asTree(prefix
, buf
);