From 43b7c21677e9ca8a195c1dcc91d7b4f795ac02a4 Mon Sep 17 00:00:00 2001 From: gjoranv Date: Thu, 5 Jan 2023 13:05:42 +0100 Subject: Extract record for BsnVersion for usage outside jdisc_core. --- .../main/java/com/yahoo/jdisc/core/BsnVersion.java | 21 +++++++++++++++++ .../com/yahoo/jdisc/core/BundleCollisionHook.java | 27 ---------------------- 2 files changed, 21 insertions(+), 27 deletions(-) create mode 100644 jdisc_core/src/main/java/com/yahoo/jdisc/core/BsnVersion.java (limited to 'jdisc_core/src/main') diff --git a/jdisc_core/src/main/java/com/yahoo/jdisc/core/BsnVersion.java b/jdisc_core/src/main/java/com/yahoo/jdisc/core/BsnVersion.java new file mode 100644 index 00000000000..ee9ecc9fc3e --- /dev/null +++ b/jdisc_core/src/main/java/com/yahoo/jdisc/core/BsnVersion.java @@ -0,0 +1,21 @@ +package com.yahoo.jdisc.core; + +import org.osgi.framework.Bundle; +import org.osgi.framework.Version; + +/** + * A bundle's symbolic name and version. + * + * @author gjoranv + */ +public record BsnVersion(String symbolicName, Version version) { + + public BsnVersion(Bundle bundle) { + this(bundle.getSymbolicName(), bundle.getVersion()); + } + + public String toReadableString() { + return symbolicName + " version:" + version; + } + +} diff --git a/jdisc_core/src/main/java/com/yahoo/jdisc/core/BundleCollisionHook.java b/jdisc_core/src/main/java/com/yahoo/jdisc/core/BundleCollisionHook.java index 3212bb4e6de..e78f3251890 100644 --- a/jdisc_core/src/main/java/com/yahoo/jdisc/core/BundleCollisionHook.java +++ b/jdisc_core/src/main/java/com/yahoo/jdisc/core/BundleCollisionHook.java @@ -129,31 +129,4 @@ public class BundleCollisionHook implements CollisionHook, EventHook, FindHook { } } - - static class BsnVersion { - - private final String symbolicName; - private final Version version; - - BsnVersion(Bundle bundle) { - this.symbolicName = bundle.getSymbolicName(); - this.version = bundle.getVersion(); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - BsnVersion that = (BsnVersion) o; - return Objects.equals(symbolicName, that.symbolicName) && - version.equals(that.version); - } - - @Override - public int hashCode() { - return Objects.hash(symbolicName, version); - } - - } - } -- cgit v1.2.3