# Class ModuleRevisionBuilder

java.lang.Object
org.eclipse.osgi.container.ModuleRevisionBuilder

public final class ModuleRevisionBuilder extends Object
A builder for creating module `ModuleRevision` objects. A builder can only be used by the module `container` to build revisions when `installing` or `updating` a module.

The builder provides the instructions to the container for creating a `ModuleRevision`. They are not thread-safe; in the absence of external synchronization, they do not support concurrent access by multiple threads.

Since:
  3.10

## Nested Class Summary

Nested Classes
Modifier and Type
Class
Description
`static class`
`ModuleRevisionBuilder.GenericInfo`
Provides information about a capability or requirement

## Constructor Summary

Constructors
Constructor
Description
`ModuleRevisionBuilder()`
Constructs a new module builder

## Method Summary

Modifier and Type
Method
Description
`void`
`addCapability(String namespace, Map<String,String> directives, Map<String,Object> attributes)`
Adds a capability to this builder using the specified namespace, directives and attributes
`void`
`addRequirement(String namespace, Map<String,String> directives, Map<String,Object> attributes)`
Adds a requirement to this builder using the specified namespace, directives and attributes
`List<ModuleRevisionBuilder.GenericInfo>`
`getCapabilities()`
Returns a snapshot of the capabilities for this builder
`List<ModuleRevisionBuilder.GenericInfo>`
`getCapabilities(String namespace)`
Returns a snapshot of the capabilities in the given namespace for this builder
`long`
`getId()`
Returns the module id for this builder.
`List<ModuleRevisionBuilder.GenericInfo>`
`getRequirements()`
Returns a snapshot of the requirements for this builder
`List<ModuleRevisionBuilder.GenericInfo>`
`getRequirements(String namespace)`
Returns a snapshot of the requirements in the given namespace for this builder
`String`
`getSymbolicName()`
Returns the symbolic name for this builder.
`int`
`getTypes()`
Returns the module type for this builder.
`Version`
`getVersion()`
Returns the module version for this builder.
`void`
`setId(long id)`
Sets the module ID for the builder.
`void`
`setSymbolicName(String symbolicName)`
Sets the symbolic name for the builder
`void`
`setTypes(int types)`
Sets the module types for the builder.
`void`
`setVersion(Version version)`
Sets the module version for the builder.

### Methods inherited from class Object

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

## Constructor Details

### ModuleRevisionBuilder

public ModuleRevisionBuilder()
Constructs a new module builder

## Method Details

### setSymbolicName

public void setSymbolicName(String symbolicName)
Sets the symbolic name for the builder

Parameters:
  `symbolicName` - the symbolic name

### setVersion

public void setVersion(Version version)
Sets the module version for the builder.

Parameters:
  `version` - the version

### setTypes

public void setTypes(int types)
Sets the module types for the builder.

Parameters:
  `types` - the module types

### setId

public void setId(long id)
Sets the module ID for the builder.

This module ID will be used if this builder is used to `install` a module. If the ID is not set then a module ID will be generated by the module container at install time. If a module already exists with the specified ID then an error will occur when attempting to install a new module with this builder.

Note that the system module with location `Constants.SYSTEM_BUNDLE_LOCATION` always gets module ID of zero. The builder for the system module is not asked to provide the module ID for the system module at install time.

Parameters:
  `id` - the module ID to use. Must be >= 1.
Since:
  3.13

### addCapability

public void addCapability(String namespace, Map<String,String> directives, Map<String,Object> attributes)
Adds a capability to this builder using the specified namespace, directives and attributes

Parameters:
  `namespace` - the namespace of the capability
  `directives` - the directives of the capability
  `attributes` - the attributes of the capability

### getCapabilities

public List<ModuleRevisionBuilder.GenericInfo> getCapabilities()
Returns a snapshot of the capabilities for this builder

Returns:
  the capabilities

### getCapabilities

public List<ModuleRevisionBuilder.GenericInfo> getCapabilities(String namespace)
Returns a snapshot of the capabilities in the given namespace for this builder

Parameters:
  `namespace` - The namespace of the capabilities to return or null to return the capabilities from all namespaces.
Returns:
  the capabilities
Since:
  3.17

### addRequirement

public void addRequirement(String namespace, Map<String,String> directives, Map<String,Object> attributes)
Adds a requirement to this builder using the specified namespace, directives and attributes

Parameters:
  `namespace` - the namespace of the requirement
  `directives` - the directives of the requirement
  `attributes` - the attributes of the requirement

### getRequirements

public List<ModuleRevisionBuilder.GenericInfo> getRequirements()
Returns a snapshot of the requirements for this builder

Returns:
  the requirements

### getRequirements

public List<ModuleRevisionBuilder.GenericInfo> getRequirements(String namespace)
Returns a snapshot of the requirements in the given namespace for this builder

Parameters:
  `namespace` - The namespace of the requirements to return or null to return the requirements from all namespaces.
Returns:
  the requirements
Since:
  3.17

### getSymbolicName

public String getSymbolicName()
Returns the symbolic name for this builder.

Returns:
  the symbolic name for this builder.

### getVersion

public Version getVersion()
Returns the module version for this builder.

Returns:
  the module version for this builder.

### getTypes

public int getTypes()
Returns the module type for this builder.

Returns:
  the module type for this builder.

### getId

public long getId()
Returns the module id for this builder. A value of -1 indicates that the module ID will be generated by the module container at `install` time.

Returns:
  the module id for this builder.
Since:
  3.13