SLING-8783 : Create API for api regions
diff --git a/src/main/java/org/apache/sling/feature/extension/apiregions/api/ApiExport.java b/src/main/java/org/apache/sling/feature/extension/apiregions/api/ApiExport.java
index 88ff28d..413e87f 100644
--- a/src/main/java/org/apache/sling/feature/extension/apiregions/api/ApiExport.java
+++ b/src/main/java/org/apache/sling/feature/extension/apiregions/api/ApiExport.java
@@ -24,7 +24,7 @@
/**
* Describes an exported package.
*/
-public class ApiExport {
+public class ApiExport implements Comparable<ApiExport> {
private final String name;
@@ -63,7 +63,7 @@
/**
* Set the toggle info.
- *
+ *
* @param toggle The toggle info
*/
public void setToggle(String toggle) {
@@ -72,7 +72,7 @@
/**
* Get the previous version of this api
- *
+ *
* @return The previous version or {@code null}
*/
public ArtifactId getPrevious() {
@@ -81,7 +81,7 @@
/**
* Set the previous version
- *
+ *
* @param previous Previus version
*/
public void setPrevious(ArtifactId previous) {
@@ -98,6 +98,11 @@
}
@Override
+ public int compareTo(final ApiExport o) {
+ return this.name.compareTo(o.name);
+ }
+
+ @Override
public String toString() {
return "ApiExport [name=" + name + ", toggle=" + toggle + ", previous=" + previous + ", properties="
+ properties + "]";
diff --git a/src/main/java/org/apache/sling/feature/extension/apiregions/api/ApiRegion.java b/src/main/java/org/apache/sling/feature/extension/apiregions/api/ApiRegion.java
index ba77277..c602a5e 100644
--- a/src/main/java/org/apache/sling/feature/extension/apiregions/api/ApiRegion.java
+++ b/src/main/java/org/apache/sling/feature/extension/apiregions/api/ApiRegion.java
@@ -28,6 +28,9 @@
*/
public class ApiRegion {
+ /** Name of the global region. */
+ public static final String GLOBAL = "global";
+
private final List<ApiExport> exports = new ArrayList<>();
private final Map<String, String> properties = new HashMap<>();
@@ -88,6 +91,15 @@
}
/**
+ * Check if the region has exports
+ *
+ * @return {@code true} if it has any export
+ */
+ public boolean isEmpty() {
+ return this.exports.isEmpty();
+ }
+
+ /**
* Unmodifiable collection of exports for this region
*
* @return The collection of exports
diff --git a/src/main/java/org/apache/sling/feature/extension/apiregions/api/ApiRegions.java b/src/main/java/org/apache/sling/feature/extension/apiregions/api/ApiRegions.java
index 86d700a..17b86b4 100644
--- a/src/main/java/org/apache/sling/feature/extension/apiregions/api/ApiRegions.java
+++ b/src/main/java/org/apache/sling/feature/extension/apiregions/api/ApiRegions.java
@@ -78,6 +78,15 @@
}
/**
+ * Check if any region exists
+ *
+ * @return {@code true} if it has any region
+ */
+ public boolean isEmpty() {
+ return this.regions.isEmpty();
+ }
+
+ /**
* Add the region. The region is only added if there isn't already a region with
* the same name
*