X-Git-Url: https://git.argeo.org/?a=blobdiff_plain;f=org.argeo.api.slc%2Fsrc%2Forg%2Fargeo%2Fapi%2Fslc%2FNameVersion.java;fp=org.argeo.api.slc%2Fsrc%2Forg%2Fargeo%2Fapi%2Fslc%2FNameVersion.java;h=0101d594a712b9baf94b0bd93bacd38eb8b357e8;hb=d07cf3c7dfdeafa2b1efafe547b54d56a8b52ced;hp=0000000000000000000000000000000000000000;hpb=8596685647867307b862b8a89742b6a62ba75fcd;p=gpl%2Fargeo-slc.git 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 index 000000000..0101d594a --- /dev/null +++ b/org.argeo.api.slc/src/org/argeo/api/slc/NameVersion.java @@ -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]; + } +}