All Downloads are FREE. Search and download functionalities are using the official Maven repository.

aQute.bnd.osgi.BundleId Maven / Gradle / Ivy

Go to download

The bndlib project is a general library to be used with OSGi bundles. It contains lots of cool functionality that calculates dependencies, etc.

There is a newer version: 2.4.0
Show newest version
package aQute.bnd.osgi;

/**
 * Holds the bundle bsn + version pair
 */
public class BundleId implements Comparable {
	final String	bsn;
	final String	version;

	public BundleId(String bsn, String version) {
		this.bsn = bsn.trim();
		this.version = version.trim();
	}

	public String getVersion() {
		return version;
	}

	public String getBsn() {
		return bsn;
	}

	public boolean isValid() {
		return Verifier.isVersion(version) && Verifier.isBsn(bsn);
	}

	@Override
	public boolean equals(Object o) {
		return this == o || ((o instanceof BundleId) && compareTo((BundleId) o) == 0);
	}

	@Override
	public int hashCode() {
		return bsn.hashCode() ^ version.hashCode();
	}

	public int compareTo(BundleId other) {
		int result = bsn.compareTo(other.bsn);
		if (result != 0)
			return result;

		return version.compareTo(other.version);
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy