Package org.apache.sling.feature

# Class Feature

java.lang.Object
org.apache.sling.feature.Feature

All Implemented Interfaces:
  `Serializable`, `Comparable<Feature>`

public class Feature extends Object implements Comparable<Feature>, Serializable
A feature consists of

- A unique id `ArtifactId`
- Bundles
- Configurations
- Framework properties
- Requirements and capabilities
- Prototype
- Extensions

This class is not thread-safe.

See Also:
  - Serialized Form

## Constructor Summary

Constructors
Constructor
Description
`Feature(ArtifactId id)`
Construct a new feature.

## Method Summary

Modifier and Type
Method
Description
`int`
`compareTo(Feature o)`
`Feature`
`copy()`
Create a copy of the feature
`Feature`
`copy(ArtifactId id)`
Create a copy of the feature with a different id For contained items like bundles, artifacts and configurations a copy is created as well.
`boolean`
`equals(Object obj)`
`Bundles`
`getBundles()`
Get the bundles.
`List<org.osgi.resource.Capability>`
`getCapabilities()`
Get the list of capabilities.
`List<String>`
`getCategories()`
Get the list of categories
`Configurations`
`getConfigurations()`
Get the configurations.
`String`
`getDescription()`
Get the description
`String`
`getDocURL()`
Get the optional document URL
`Extensions`
`getExtensions()`
Get the list of extensions.
`List<ArtifactId>`
`getFeatureOrigins(Map<String,Object> metadata)`
Get the feature origins for the metadata- if recorded
`Map<String,String>`
`getFrameworkProperties()`
Get the framework properties The returned object is modifiable.
`Map<String,Object>`
`getFrameworkPropertyMetadata(String key)`
Return a mutable map of metadata for the framework property
`ArtifactId`
`getId()`
Get the id of the artifact.
`String`
`getLicense()`
Get the license
`String`
`getLocation()`
Get the location.
`Prototype`
`getPrototype()`
Get the optional prototype feature.
`List<MatchingRequirement>`
`getRequirements()`
Get the list of requirements.
`String`
`getSCMInfo()`
Get the SCM information relating to the feature.
`String`
`getTitle()`
Get the title
`Map<String,Object>`
`getVariableMetadata(String key)`
Return a mutable map of metadata for the variable
`Map<String,String>`
`getVariables()`
Obtain the variables of the feature
`String`
`getVendor()`
Get the vendor
`int`
`hashCode()`
`boolean`
`isAssembled()`
Check whether the feature is already assembled
`boolean`
`isComplete()`
Check whether the feature is complete.
`boolean`
`isFinal()`
Check whether the feature is final.
`void`
`setAssembled(boolean flag)`
Set the assembled flag
`void`
`setComplete(boolean flag)`
Set the complete flag
`void`
`setDescription(String description)`
Set the description
`void`
`setDocURL(String url)`
Set the document URL
`void`
`setFeatureOrigins(Map<String,Object> metadata, List<ArtifactId> featureOrigins)`
Set the feature origins for the metadata
`void`
`setFinal(boolean flag)`
Set the final flag
`void`
`setLicense(String license)`
Set the vendor
`void`
`setLocation(String value)`
Set the location.
`void`
`setPrototype(Prototype prototype)`
Set the optional prototype feature.
`void`
`setSCMInfo(String info)`
Set the SCM information
`void`
`setTitle(String title)`
Set the title
`void`
`setVendor(String vendor)`
Set the vendor
`String`
`toString()`

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

`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

## Constructor Details

### Feature

public Feature(ArtifactId id)
Construct a new feature.

Parameters:
  `id` - The id of the feature.
Throws:
  `IllegalArgumentException` - If id is `null`.

## Method Details

### getId

public ArtifactId getId()
Get the id of the artifact.

Returns:
  The id.

### getLocation

public String getLocation()
Get the location. The location might be the location of the feature file or any other means identifying where the object is defined.

Returns:
  The location or `null`.

### setLocation

public void setLocation(String value)
Set the location.

Parameters:
  `value` - The new location.

### getBundles

public Bundles getBundles()
Get the bundles.

Returns:
  The bundles object.

### getConfigurations

public Configurations getConfigurations()
Get the configurations. The returned object is modifiable.

Returns:
  The configurations

### getFrameworkProperties

public Map<String,String> getFrameworkProperties()
Get the framework properties The returned object is modifiable.

Returns:
  The framework properties

### getRequirements

public List<MatchingRequirement> getRequirements()
Get the list of requirements. The returned object is modifiable.

Returns:
  The list of requirements

### getCapabilities

public List<org.osgi.resource.Capability> getCapabilities()
Get the list of capabilities. The returned object is modifiable.

Returns:
  The list of capabilities

### getPrototype

public Prototype getPrototype()
Get the optional prototype feature.

Returns:
  The prototype feature or `null` if none.

### setPrototype

public void setPrototype(Prototype prototype)
Set the optional prototype feature.

Parameters:
  `prototype` - The prototype feature or `null` if none.

### getExtensions

public Extensions getExtensions()
Get the list of extensions. The returned object is modifiable.

Returns:
  The list of extensions

### getTitle

public String getTitle()
Get the title

Returns:
  The title or `null`

### setTitle

public void setTitle(String title)
Set the title

Parameters:
  `title` - The title

### getDescription

public String getDescription()
Get the description

Returns:
  The description or `null`

### setDescription

public void setDescription(String description)
Set the description

Parameters:
  `description` - The description

### getVariables

public Map<String,String> getVariables()
Obtain the variables of the feature

Returns:
  The variables

### getVendor

public String getVendor()
Get the vendor

Returns:
  The vendor or `null`

### setVendor

public void setVendor(String vendor)
Set the vendor

Parameters:
  `vendor` - The vendor

### getLicense

public String getLicense()
Get the license

Returns:
  The license or `null`

### setLicense

public void setLicense(String license)
Set the vendor

Parameters:
  `license` - The license

### isFinal

public boolean isFinal()
Check whether the feature is final. A final feature can't be a prototype for other features.

Returns:
  `true` if it is final, `false` otherwise

### setFinal

public void setFinal(boolean flag)
Set the final flag

Parameters:
  `flag` - The flag

### isComplete

public boolean isComplete()
Check whether the feature is complete. A complete feature has no external dependencies and can run as-is.

Returns:
  `true` if it is complete, `false` otherwise

### setComplete

public void setComplete(boolean flag)
Set the complete flag

Parameters:
  `flag` - The flag

### isAssembled

public boolean isAssembled()
Check whether the feature is already assembled

Returns:
  `true` if it is assembled, `false` if it needs to be assembled

### setAssembled

public void setAssembled(boolean flag)
Set the assembled flag

Parameters:
  `flag` - The flag

### getFrameworkPropertyMetadata

public Map<String,Object> getFrameworkPropertyMetadata(String key)
Return a mutable map of metadata for the framework property

Parameters:
  `key` - The name of the property.
Returns:
  A mutable map or `null` if the framework property does not exist
Since:
  1.7.0

### getVariableMetadata

public Map<String,Object> getVariableMetadata(String key)
Return a mutable map of metadata for the variable

Parameters:
  `key` - The name of the variable.
Returns:
  A mutable map or `null` if the variable does not exist
Since:
  1.7.0

### getFeatureOrigins

public List<ArtifactId> getFeatureOrigins(Map<String,Object> metadata)
Get the feature origins for the metadata- if recorded

Parameters:
  `metadata` - The metadata (for a variable or framework property)
Returns:
  A immutable list of feature artifact ids - list is never empty
Throws:
  `IllegalArgumentException` - If the stored values are not valid artifact ids
Since:
  1.7

### setFeatureOrigins

public void setFeatureOrigins(Map<String,Object> metadata, List<ArtifactId> featureOrigins)
Set the feature origins for the metadata

Parameters:
  `metadata` - The metadata (for a variable or framework property)
  `featureOrigins` - the list of artifact ids or null to remove the info from this object
Since:
  1.7

### getCategories

public List<String> getCategories()
Get the list of categories

Returns:
  The modifiable list, might be empty
Since:
  1.9

### getDocURL

public String getDocURL()
Get the optional document URL

Returns:
  The document URL or `null`
Since:
  1.9

### setDocURL

public void setDocURL(String url)
Set the document URL

Parameters:
  `url` - The url
Since:
  1.9

### getSCMInfo

public String getSCMInfo()
Get the SCM information relating to the feature. The syntax of the value follows the Bundle-SCM format. See the 'Bundle Manifest Headers' section in the OSGi Core specification.

Returns:
  The SCM information or `null`
Since:
  1.9

### setSCMInfo

public void setSCMInfo(String info)
Set the SCM information

Parameters:
  `info` - The SCM information
Since:
  1.9
See Also:
  - `getSCMInfo()`

### copy

public Feature copy()
Create a copy of the feature

Returns:
  A copy of the feature

### copy

public Feature copy(ArtifactId id)
Create a copy of the feature with a different id For contained items like bundles, artifacts and configurations a copy is created as well.

Parameters:
  `id` - The new id
Returns:
  The copy of the feature with the new id

### compareTo

public int compareTo(Feature o)

Specified by:
  `compareTo` in interface `Comparable<Feature>`

### hashCode

public int hashCode()

Overrides:
  `hashCode` in class `Object`

### equals

public boolean equals(Object obj)

Overrides:
  `equals` in class `Object`

### toString

public String toString()

Overrides:
  `toString` in class `Object`