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";
17 final static String LIB
= "lib";
19 private final ProvisioningSource source
;
20 private final String id
;
22 final Map
<String
, A2Component
> components
= Collections
.synchronizedSortedMap(new TreeMap
<>());
25 * The contribution must be added to the source. Rather use
26 * {@link AbstractProvisioningSource#getOrAddContribution(String)} than this
27 * contructor directly.
29 public A2Contribution(ProvisioningSource context
, String id
) {
30 this.source
= context
;
32 // if (context != null)
33 // context.contributions.put(id, this);
36 public Iterable
<A2Component
> listComponents(Object filter
) {
37 return components
.values();
40 A2Component
getOrAddComponent(String componentId
) {
41 if (components
.containsKey(componentId
))
42 return components
.get(componentId
);
44 return new A2Component(this, componentId
);
47 public ProvisioningSource
getSource() {
51 public String
getId() {
56 public int compareTo(A2Contribution o
) {
57 return id
.compareTo(o
.id
);
61 public int hashCode() {
66 public boolean equals(Object obj
) {
67 if (obj
instanceof A2Contribution
) {
68 A2Contribution o
= (A2Contribution
) obj
;
69 return id
.equals(o
.id
);
75 public String
toString() {
79 void asTree(String prefix
, StringBuffer buf
) {
82 for (String componentId
: components
.keySet()) {
84 buf
.append(componentId
);
85 A2Component component
= components
.get(componentId
);
86 component
.asTree(prefix
, buf
);
91 static String
localOsArchRelativePath() {
92 return Os
.local().toString() + "/" + Arch
.local().toString();
96 LINUX
, WIN32
, MACOSX
, UNKOWN
;
99 public String
toString() {
100 return name().toLowerCase();
103 public static Os
local() {
104 String osStr
= System
.getProperty("os.name").toLowerCase();
105 if (osStr
.startsWith("linux"))
107 if (osStr
.startsWith("win"))
109 if (osStr
.startsWith("mac"))
117 X86_64
, AARCH64
, X86
, POWERPC
, UNKOWN
;
120 public String
toString() {
121 return name().toLowerCase();
124 public static Arch
local() {
125 String archStr
= System
.getProperty("os.arch").toLowerCase();
126 return switch (archStr
) {