View Javadoc
1   package org.argeo.osgi.a2;
2   
3   import org.osgi.framework.Version;
4   
5   /**
6    * An identified software package. In OSGi's case this is the combination of
7    * <code>Bundle-SymbolicName</code> and <code>Bundle-version</code>. This is the
8    * equivalent of the full coordinates of a Maven artifact version.
9    */
10  class A2Module implements Comparable<A2Module> {
11  	private final A2Branch branch;
12  	private final Version version;
13  	private final Object locator;
14  
15  	public A2Module(A2Branch branch, Version version, Object locator) {
16  		this.branch = branch;
17  		this.version = version;
18  		this.locator = locator;
19  		branch.modules.put(version, this);
20  	}
21  
22  	A2Branch getBranch() {
23  		return branch;
24  	}
25  
26  	Version getVersion() {
27  		return version;
28  	}
29  
30  	Object getLocator() {
31  		return locator;
32  	}
33  
34  	@Override
35  	public int compareTo(A2Module o) {
36  		return version.compareTo(o.version);
37  	}
38  
39  	@Override
40  	public int hashCode() {
41  		return version.hashCode();
42  	}
43  
44  	@Override
45  	public boolean equals(Object obj) {
46  		if (obj instanceof A2Module) {
47  			A2Module o = (A2Module) obj;
48  			return branch.equals(o.branch) && version.equals(o.version);
49  		} else
50  			return false;
51  	}
52  
53  	@Override
54  	public String toString() {
55  		return getCoordinates();
56  	}
57  
58  	public String getCoordinates() {
59  		return branch.getComponent() + ":" + version;
60  	}
61  
62  }