Class ApiRegions
- 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 Summary
Fields Modifier and Type Field Description static StringEXTENSION_NAMEThe name of the api regions extension.
-
Constructor Summary
Constructors Constructor Description ApiRegions()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanadd(int idx, ApiRegion region)Add the region.booleanadd(ApiRegion region)Add the region.booleanequals(Object obj)static ApiRegionsgetApiRegions(org.apache.sling.feature.Extension ext)Get the api regions from the extension.static ApiRegionsgetApiRegions(org.apache.sling.feature.Feature feature)Get the api regions from the feature - if it exists.ApiRegiongetRegionByName(String name)Get a named regionList<String>getRegionNames()Get the names of the regionsApiRegion[]getRegionsByFeature(org.apache.sling.feature.ArtifactId featureId)ApiRegiongetRoot()Get the root regions.inthashCode()booleanisEmpty()Check if any region existsList<ApiRegion>listRegions()Return the list of regionsstatic ApiRegionsparse(jakarta.json.JsonArray json)Parse a JSON array into an api regions objectstatic ApiRegionsparse(String json)Parse a JSON array into an api regions objectStringtoJSON()Convert regions into jsonjakarta.json.JsonArraytoJSONArray()Convert regions into jsonStringtoString()
-
-
-
Field Detail
-
EXTENSION_NAME
public static final String EXTENSION_NAME
The name of the api regions extension.- See Also:
- Constant Field Values
-
-
Method Detail
-
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:
trueif 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:
trueif the region could be added,falseotherwise
-
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 addregion- The region to add- Returns:
trueif the region could be added,falseotherwise
-
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 IOExceptionConvert 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
-
-