blob: e500e53e38af5eec42ac517cf2e7c40918058b06 [file] [log] [blame]
Stuart McCullochbb014372012-06-07 21:57:32 +00001package aQute.lib.osgi;
2
3
4/**
5 * Holds the bundle bsn + version pair
6 *
7 */
8public class BundleId implements Comparable<BundleId> {
9 final String bsn;
10 final String version;
11
12 public BundleId(String bsn, String version) {
13 this.bsn = bsn.trim();
14 this.version = version.trim();
15 }
16
17 public String getVersion() {
18 return version;
19 }
20
21 public String getBsn() {
22 return bsn;
23 }
24
25 public boolean isValid() {
26 return Verifier.isVersion(version) && Verifier.isBsn(bsn);
27 }
28
29 public boolean equals(Object o) {
30 return this == o || ((o instanceof BundleId) && compareTo((BundleId) o) == 0);
31 }
32
33 public int hashCode() {
34 return bsn.hashCode() ^ version.hashCode();
35 }
36
37 public int compareTo(BundleId other) {
38 int result = bsn.compareTo(other.bsn);
39 if ( result != 0)
40 return result;
41
42 return version.compareTo(other.version);
43 }
44}