java.lang.Object
org.apache.sling.feature.extension.apiregions.api.ApiRegions

public class ApiRegions extends Object
Configuration of API regions for Java API. This class is not thread safe.
  • Field Details

  • Constructor Details

    • ApiRegions

      public ApiRegions()
  • Method Details

    • listRegions

      public List<ApiRegion> listRegions()
      Return the list of regions
      Returns:
      Unmodifiable list of regions, might be empty
    • getRoot

      public ApiRegion getRoot()
      Get the root regions. The root is the region which does not have a parent
      Returns:
      The root region or null
    • isEmpty

      public boolean isEmpty()
      Check if any region exists
      Returns:
      true if it has any region
    • add

      public boolean add(ApiRegion region)
      Add the region. The region is only added if there isn't already a region with the same name
      Parameters:
      region - The region to add
      Returns:
      true if the region could be added, false otherwise
    • add

      public boolean add(int idx, ApiRegion region)
      Add the region. The region is only added if there isn't already a region with the same name
      Parameters:
      idx - The position to add
      region - The region to add
      Returns:
      true if the region could be added, false otherwise
    • getRegionByName

      public ApiRegion getRegionByName(String name)
      Get a named region
      Parameters:
      name - The name
      Returns:
      The region or null
    • getRegionsByFeature

      public ApiRegion[] getRegionsByFeature(org.apache.sling.feature.ArtifactId featureId)
    • getRegionNames

      public List<String> getRegionNames()
      Get the names of the regions
      Returns:
      The list of regions, might be empty
    • toJSONArray

      public jakarta.json.JsonArray toJSONArray() throws IOException
      Convert regions into json
      Returns:
      The json array
      Throws:
      IOException - If generating the JSON fails
    • toJSON

      public String toJSON() throws IOException
      Convert regions into json
      Returns:
      The json array as a string
      Throws:
      IOException - If generating the JSON fails
    • parse

      public static ApiRegions parse(String json) throws IOException
      Parse a JSON array into an api regions object
      Parameters:
      json - The json as a string
      Returns:
      The api regions
      Throws:
      IOException - If the json could not be parsed
    • parse

      public static ApiRegions parse(jakarta.json.JsonArray json) throws IOException
      Parse a JSON array into an api regions object
      Parameters:
      json - The json
      Returns:
      The api regions
      Throws:
      IOException - If the json could not be parsed
    • getApiRegions

      public static ApiRegions getApiRegions(org.apache.sling.feature.Feature feature)
      Get the api regions from the feature - if it exists.
      Parameters:
      feature - The feature
      Returns:
      The api regions or null.
      Throws:
      IllegalArgumentException - If the extension is wrongly formatted
      Since:
      1.1
    • getApiRegions

      public static ApiRegions getApiRegions(org.apache.sling.feature.Extension ext)
      Get the api regions from the extension.
      Parameters:
      ext - The extension
      Returns:
      The api regions or null.
      Throws:
      IllegalArgumentException - If the extension is wrongly formatted
      Since:
      1.1
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object