X-Git-Url: http://git.argeo.org/?p=lgpl%2Fargeo-commons.git;a=blobdiff_plain;f=org.argeo.init%2Fsrc%2Forg%2Fargeo%2Finit%2Fa2%2FA2Branch.java;fp=org.argeo.init%2Fsrc%2Forg%2Fargeo%2Finit%2Fa2%2FA2Branch.java;h=0000000000000000000000000000000000000000;hp=cd8d8954142f4dfc1a1942b652e2a6932e165b9d;hb=b95462873703848193e56fcbe997693630db6121;hpb=55d88fba80cec198a0f11ba7545e19878c51fc5e diff --git a/org.argeo.init/src/org/argeo/init/a2/A2Branch.java b/org.argeo.init/src/org/argeo/init/a2/A2Branch.java deleted file mode 100644 index cd8d89541..000000000 --- a/org.argeo.init/src/org/argeo/init/a2/A2Branch.java +++ /dev/null @@ -1,89 +0,0 @@ -package org.argeo.init.a2; - -import java.util.Collections; -import java.util.SortedMap; -import java.util.TreeMap; - -import org.argeo.init.osgi.OsgiBootUtils; -import org.osgi.framework.Version; - -/** - * A logical linear sequence of versions of a given {@link A2Component}. This is - * typically a combination of major and minor version, indicating backward - * compatibility. - */ -public class A2Branch implements Comparable { - private final A2Component component; - private final String id; - - final SortedMap modules = Collections.synchronizedSortedMap(new TreeMap<>()); - - public A2Branch(A2Component component, String id) { - this.component = component; - this.id = id; - component.branches.put(id, this); - } - - public Iterable listModules(Object filter) { - return modules.values(); - } - - A2Module getOrAddModule(Version version, Object locator) { - if (modules.containsKey(version)) { - A2Module res = modules.get(version); - if (OsgiBootUtils.isDebug() && !res.getLocator().equals(locator)) { - OsgiBootUtils.debug("Inconsistent locator " + locator + " (registered: " + res.getLocator() + ")"); - } - return res; - } else - return new A2Module(this, version, locator); - } - - public A2Module last() { - return modules.get(modules.lastKey()); - } - - public A2Module first() { - return modules.get(modules.firstKey()); - } - - public A2Component getComponent() { - return component; - } - - public String getId() { - return id; - } - - @Override - public int compareTo(A2Branch o) { - return id.compareTo(id); - } - - @Override - public int hashCode() { - return id.hashCode(); - } - - @Override - public boolean equals(Object obj) { - if (obj instanceof A2Branch) { - A2Branch o = (A2Branch) obj; - return component.equals(o.component) && id.equals(o.id); - } else - return false; - } - - @Override - public String toString() { - return getCoordinates(); - } - - public String getCoordinates() { - return component + ":" + id; - } - - static String versionToBranchId(Version version) { - return version.getMajor() + "." + version.getMinor(); - } -}