Package org.apache.sling.feature.extension.apiregions.api.config

# Class AttributeableEntity

java.lang.Object
org.apache.sling.feature.extension.apiregions.api.config.AttributeableEntity

Direct Known Subclasses:
  `ArtifactRules`, `ConfigurableEntityAddition`, `ConfigurationApi`, `DescribableEntity`, `PropertyDescriptionAddition`, `Range`, `VersionRule`

public abstract class AttributeableEntity extends Object
Abstract class used by all entities which allow additional attributes to be stored. This class is not thread safe.

## Constructor Summary

Constructors
Constructor
Description
`AttributeableEntity()`

## Method Summary

Modifier and Type
Method
Description
`void`
`clear()`
Clear the object and reset to defaults
`protected jakarta.json.JsonObjectBuilder`
`createJson()`
Convert this object into JSON
`void`
`fromJSONObject(jakarta.json.JsonObject jsonObj)`
Extract the metadata from the JSON object.
`Map<String,jakarta.json.JsonValue>`
`getAttributes()`
Get the attributes
`protected boolean`
`getBoolean(String attributeName, boolean defaultValue)`
Helper method to get a boolean value from an attribute
`protected int`
`getInteger(String attributeName, int defaultValue)`
Helper method to get a integer value from an attribute
`protected Number`
`getNumber(String attributeName)`
Helper method to get a number value from an attribute
`protected String`
`getString(jakarta.json.JsonValue jsonValue)`
Helper method to get a string value from a JsonValue
`protected String`
`getString(String attributeName)`
Helper method to get a string value from an attribute
`protected String[]`
`getStringArray(String attributeName)`
Helper method to get a string array from an attribute
`protected void`
`setDefaults()`
Apply the non-null default values.
`protected void`
`setString(jakarta.json.JsonObjectBuilder builder, String attributeName, String value)`
Helper method to set a string value
`protected void`
`setStringArray(jakarta.json.JsonObjectBuilder builder, String attributeName, String[] value)`
Helper method to set a string array
`jakarta.json.JsonObject`
`toJSONObject()`
Convert this object into JSON

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### AttributeableEntity

public AttributeableEntity()

## Method Details

### setDefaults

protected void setDefaults()
Apply the non-null default values.

### clear

public void clear()
Clear the object and reset to defaults

### toJSONObject

public jakarta.json.JsonObject toJSONObject() throws IOException
Convert this object into JSON

Returns:
  The json object
Throws:
  `IOException` - If generating the JSON fails

### fromJSONObject

public void fromJSONObject(jakarta.json.JsonObject jsonObj) throws IOException
Extract the metadata from the JSON object. This method first calls `clear()`

Parameters:
  `jsonObj` - The JSON Object
Throws:
  `IOException` - If JSON parsing fails

### getAttributes

public Map<String,jakarta.json.JsonValue> getAttributes()
Get the attributes

Returns:
  Mutable map of attributes, by attribute name

### createJson

protected jakarta.json.JsonObjectBuilder createJson() throws IOException
Convert this object into JSON

Returns:
  The json object builder
Throws:
  `IOException` - If generating the JSON fails

### getString

protected String getString(jakarta.json.JsonValue jsonValue)
Helper method to get a string value from a JsonValue

Parameters:
  `jsonValue` - The json value
Returns:
  The string value or `null`.

### getString

protected String getString(String attributeName)
Helper method to get a string value from an attribute

Parameters:
  `attributeName` - The attribute name
Returns:
  The string value or `null`.

### getStringArray

protected String[] getStringArray(String attributeName) throws IOException
Helper method to get a string array from an attribute

Parameters:
  `attributeName` - The attribute name
Returns:
  The string array or `null`.
Throws:
  `IOException`
Since:
  1.6.0

### getNumber

protected Number getNumber(String attributeName) throws IOException
Helper method to get a number value from an attribute

Parameters:
  `attributeName` - The attribute name
Returns:
  The string value or `null`.
Throws:
  `IOException` - If the attribute value is not of type boolean

### setString

protected void setString(jakarta.json.JsonObjectBuilder builder, String attributeName, String value)
Helper method to set a string value

Parameters:
  `builder` - The json object builder
  `attributeName` - The name of the attribute
  `value` - The string value

### setStringArray

protected void setStringArray(jakarta.json.JsonObjectBuilder builder, String attributeName, String[] value)
Helper method to set a string array

Parameters:
  `builder` - The json object builder
  `attributeName` - The name of the attribute
  `value` - The string array
Since:
  1.6.0

### getInteger

protected int getInteger(String attributeName, int defaultValue)
Helper method to get a integer value from an attribute

Parameters:
  `attributeName` - The attribute name
  `defaultValue` - default value
Returns:
  The integer value or the default value

### getBoolean

protected boolean getBoolean(String attributeName, boolean defaultValue) throws IOException
Helper method to get a boolean value from an attribute

Parameters:
  `attributeName` - The attribute name
  `defaultValue` - default value
Returns:
  The boolean value or the default value
Throws:
  `IOException` - If the attribute value is not of type boolean