X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=org.argeo.osgi.boot%2Fsrc%2Forg%2Fargeo%2Fosgi%2Fboot%2Fa2%2FA2Component.java;fp=org.argeo.osgi.boot%2Fsrc%2Forg%2Fargeo%2Fosgi%2Fboot%2Fa2%2FA2Component.java;h=0000000000000000000000000000000000000000;hb=79e0a2a5d751c7c077e52f9ee54469656dc96a44;hp=a2d5facf98b9cfc8c814cfbe1cd5de91b19486d8;hpb=c155192cfcd5ca355eb933fa3f55dbad6d01b958;p=lgpl%2Fargeo-commons.git diff --git a/org.argeo.osgi.boot/src/org/argeo/osgi/boot/a2/A2Component.java b/org.argeo.osgi.boot/src/org/argeo/osgi/boot/a2/A2Component.java deleted file mode 100644 index a2d5facf9..000000000 --- a/org.argeo.osgi.boot/src/org/argeo/osgi/boot/a2/A2Component.java +++ /dev/null @@ -1,100 +0,0 @@ -package org.argeo.osgi.boot.a2; - -import java.util.Collections; -import java.util.SortedMap; -import java.util.TreeMap; - -import org.osgi.framework.Version; - -/** - * The logical name of a software package. In OSGi's case this is - * Bundle-SymbolicName. This is the equivalent of Maven's artifact - * id. - */ -public class A2Component implements Comparable { - private final A2Contribution contribution; - private final String id; - - final SortedMap branches = Collections.synchronizedSortedMap(new TreeMap<>()); - - public A2Component(A2Contribution contribution, String id) { - this.contribution = contribution; - this.id = id; - contribution.components.put(id, this); - } - - A2Branch getOrAddBranch(String branchId) { - if (branches.containsKey(branchId)) - return branches.get(branchId); - else - return new A2Branch(this, branchId); - } - - A2Module getOrAddModule(Version version, Object locator) { - A2Branch branch = getOrAddBranch(A2Branch.versionToBranchId(version)); - A2Module module = branch.getOrAddModule(version, locator); - return module; - } - - A2Branch last() { - return branches.get(branches.lastKey()); - } - - A2Contribution getContribution() { - return contribution; - } - - String getId() { - return id; - } - - @Override - public int compareTo(A2Component o) { - return id.compareTo(o.id); - } - - @Override - public int hashCode() { - return id.hashCode(); - } - - @Override - public boolean equals(Object obj) { - if (obj instanceof A2Component) { - A2Component o = (A2Component) obj; - return contribution.equals(o.contribution) && id.equals(o.id); - } else - return false; - } - - @Override - public String toString() { - return contribution.getId() + ":" + id; - } - - void asTree(String prefix, StringBuffer buf) { - if (prefix == null) - prefix = ""; - A2Branch lastBranch = last(); - SortedMap displayMap = new TreeMap<>(Collections.reverseOrder()); - displayMap.putAll(branches); - for (String branchId : displayMap.keySet()) { - A2Branch branch = displayMap.get(branchId); - if (!lastBranch.equals(branch)) { - buf.append('\n'); - buf.append(prefix); - } else { - buf.append(" -"); - } - buf.append(prefix); - buf.append(branchId); - A2Module first = branch.first(); - A2Module last = branch.last(); - buf.append(" (").append(last.getVersion()); - if (!first.equals(last)) - buf.append(" ... ").append(first.getVersion()); - buf.append(')'); - } - } - -}