Merge tag 'v2.3.15' into testing
[gpl/argeo-slc.git] / org.argeo.api.slc / src / org / argeo / api / slc / NameVersion.java
diff --git a/org.argeo.api.slc/src/org/argeo/api/slc/NameVersion.java b/org.argeo.api.slc/src/org/argeo/api/slc/NameVersion.java
new file mode 100644 (file)
index 0000000..0101d59
--- /dev/null
@@ -0,0 +1,24 @@
+package org.argeo.api.slc;
+
+/**
+ * Abstraction of a name / version pair, typically used as coordinates for a
+ * software module either deployed or packaged as an archive.
+ */
+public interface NameVersion {
+       /** The name of the component. */
+       String getName();
+
+       /** The version of the component. */
+       String getVersion();
+
+       /**
+        * The forward compatible branch of this version, by default it is
+        * [major].[minor].
+        */
+       default String getBranch() {
+               String[] parts = getVersion().split("\\.");
+               if (parts.length < 2)
+                       throw new IllegalStateException("Version " + getVersion() + " cannot be interpreted as branch.");
+               return parts[0] + "." + parts[1];
+       }
+}