]> git.argeo.org Git - gpl/argeo-slc.git/blob - org.argeo.slc.api/src/org/argeo/slc/CategoryNameVersion.java
Improve publishing third parties.
[gpl/argeo-slc.git] / org.argeo.slc.api / src / org / argeo / slc / CategoryNameVersion.java
1 package org.argeo.slc;
2
3 /**
4 * Adds a dimension to {@link NameVersion} by adding an arbitrary category (e.g.
5 * Maven groupId, yum repository ID, etc.)
6 */
7 public interface CategoryNameVersion extends NameVersion {
8 /** The category of the component. */
9 String getCategory();
10
11 static CategoryNameVersion parseCategoryNameVersion(String str) {
12 if (str == null || "".equals(str.trim()))
13 throw new IllegalArgumentException("At least one character required.");
14 String[] arr = str.trim().split(":");
15 if (arr.length > 3)
16 throw new IllegalArgumentException(str + " does not respect the [category]:[name]:[version] pattern");
17 DefaultCategoryNameVersion res = new DefaultCategoryNameVersion();
18 res.setCategory(arr[0]);
19 if (arr.length > 1)
20 res.setName(arr[1]);
21 if (arr.length > 2)
22 res.setVersion(arr[2]);
23 return res;
24 }
25 }