Class MetadataFactory


  • public final class MetadataFactory
    extends Object
    A factory class for instantiating various p2 metadata objects.
    Since:
    2.0
    • Constructor Detail

      • MetadataFactory

        public MetadataFactory()
    • Method Detail

      • createInstallableUnit

        public static IInstallableUnit createInstallableUnit​(MetadataFactory.InstallableUnitDescription description)
        Returns an IInstallableUnit based on the given description. Once the installable unit has been created, the information is discarded from the description object.
        Parameters:
        description - The description of the unit to create
        Returns:
        The created installable unit
      • createProvidedCapability

        public static IProvidedCapability createProvidedCapability​(String namespace,
                                                                   String name,
                                                                   Version version)
        Returns a IProvidedCapability with the given values.
        Parameters:
        namespace - The capability namespace
        name - The capability name
        version - The capability version
      • createProvidedCapability

        public static IProvidedCapability createProvidedCapability​(String namespace,
                                                                   Map<String,​Object> properties)
        Returns a IProvidedCapability with the given values.
        Parameters:
        namespace - The capability namespace
        properties - The description of the capability
        Since:
        2.4
      • createRequirement

        public static IRequirement createRequirement​(String namespace,
                                                     String name,
                                                     VersionRange range,
                                                     String filter,
                                                     boolean optional,
                                                     boolean multiple,
                                                     boolean greedy)
        Create and return a new requirement (IRequirement) with the specified values.
        Parameters:
        namespace - the namespace for the requirement. Must not be null.
        name - the name for the requirement. Must not be null.
        range - the version range. A value of null is equivalent to VersionRange.emptyRange and matches all versions.
        filter - The filter used to evaluate whether this capability is applicable in the current environment, or null to indicate this capability is always applicable
        optional - true if this requirement is optional, and false otherwise.
        multiple - true if this requirement can be satisfied by multiple provided capabilities, or false if it requires exactly one match
        greedy - true if the requirement should be considered greedy and false otherwise
        Returns:
        the requirement
      • createRequirement

        public static IRequirement createRequirement​(String namespace,
                                                     String name,
                                                     VersionRange range,
                                                     IMatchExpression<IInstallableUnit> filter,
                                                     boolean optional,
                                                     boolean multiple)
        Returns a IRequirement with the given values.
        Parameters:
        namespace - The capability namespace
        name - The required capability name
        range - The range of versions that are required, or null to indicate that any version will do.
        filter - The filter used to evaluate whether this capability is applicable in the current environment, or null to indicate this capability is always applicable
        optional - true if this required capability is optional, and false otherwise.
        multiple - true if this capability can be satisfied by multiple provided capabilities, or false if it requires exactly one match
        Returns:
        the requirement
      • createRequirement

        public static IRequirement createRequirement​(String namespace,
                                                     String name,
                                                     VersionRange range,
                                                     IMatchExpression<IInstallableUnit> filter,
                                                     int minCard,
                                                     int maxCard,
                                                     boolean greedy)
        Create and return a new requirement (IRequirement) with the specified values.
        Parameters:
        namespace - the namespace for the requirement. Must not be null.
        name - the name for the requirement. Must not be null.
        range - the version range. A value of null is equivalent to VersionRange.emptyRange and matches all versions.
        filter - The filter used to evaluate whether this capability is applicable in the current environment, or null to indicate this capability is always applicable
        minCard - minimum cardinality
        maxCard - maximum cardinality
        greedy - true if the requirement should be considered greedy and false otherwise
        Returns:
        the requirement
      • createRequirement

        public static IRequirement createRequirement​(String namespace,
                                                     String name,
                                                     VersionRange range,
                                                     IMatchExpression<IInstallableUnit> filter,
                                                     int minCard,
                                                     int maxCard,
                                                     boolean greedy,
                                                     String description)
        Create and return a new requirement (IRequirement) with the specified values.
        Parameters:
        namespace - the namespace for the requirement. Must not be null.
        name - the name for the requirement. Must not be null.
        range - the version range. A value of null is equivalent to VersionRange.emptyRange and matches all versions.
        filter - The filter used to evaluate whether this capability is applicable in the current environment, or null to indicate this capability is always applicable
        minCard - minimum cardinality
        maxCard - maximum cardinality
        greedy - true if the requirement should be considered greedy and false otherwise
        description - a String description of the requirement, or null
        Returns:
        the requirement
      • createRequirement

        public static IRequirement createRequirement​(IMatchExpression<IInstallableUnit> requirement,
                                                     IMatchExpression<IInstallableUnit> envFilter,
                                                     int minCard,
                                                     int maxCard,
                                                     boolean greedy)
        Create and return a new requirement (IRequirement) with the specified values.
        Parameters:
        requirement - the match expression
        envFilter - The filter used to evaluate whether this capability is applicable in the current environment, or null to indicate this capability is always applicable
        minCard - minimum cardinality
        maxCard - maximum cardinality
        greedy - true if the requirement should be considered greedy and false otherwise
        Returns:
        the requirement
      • createRequirement

        public static IRequirement createRequirement​(IMatchExpression<IInstallableUnit> requirement,
                                                     IMatchExpression<IInstallableUnit> envFilter,
                                                     int minCard,
                                                     int maxCard,
                                                     boolean greedy,
                                                     String description)
        Create and return a new requirement (IRequirement) with the specified values.
        Parameters:
        requirement - the match expression
        envFilter - the filter, or null
        minCard - minimum cardinality
        maxCard - maximum cardinality
        greedy - true if the requirement should be considered greedy and false otherwise
        description - a String description of the requirement, or null
        Returns:
        the requirement
      • createRequirementChange

        public static IRequirementChange createRequirementChange​(IRequirement applyOn,
                                                                 IRequirement newValue)
        Returns a new requirement change.
        Parameters:
        applyOn - The source of the requirement change - the kind of requirement to apply the change to
        newValue - The result of the requirement change - the requirement to replace the source requirement with
        Returns:
        a requirement change
      • createCopyright

        public static ICopyright createCopyright​(URI location,
                                                 String body)
        Returns a new ICopyright.
        Parameters:
        location - the location of a document containing the copyright notice, or null
        body - the copyright body, cannot be null
        Throws:
        IllegalArgumentException - when the body is null
      • createLicense

        public static ILicense createLicense​(URI location,
                                             String body)
        Return a new ILicense The body should contain either the full text of the license or an summary for a license fully specified in the given location.
        Parameters:
        location - the location of a document containing the full license, or null
        body - the license body, cannot be null
        Throws:
        IllegalArgumentException - when the body is null
      • createTouchpointData

        public static ITouchpointData createTouchpointData​(Map<String,​? extends Object> instructions)
        Returns an instance of ITouchpointData with the given instructions.
        Parameters:
        instructions - The instructions for the touchpoint data.
        Returns:
        The created touchpoint data
      • mergeTouchpointData

        public static ITouchpointData mergeTouchpointData​(ITouchpointData initial,
                                                          Map<String,​ITouchpointInstruction> incomingInstructions)
        Merge the given touchpoint instructions with a pre-existing touchpoint data
        Parameters:
        initial - - the initial ITouchpointData
        incomingInstructions - - Map of ITouchpointInstructions to merge into the initial touchpoint data
        Returns:
        the merged ITouchpointData
      • createTouchpointType

        public static ITouchpointType createTouchpointType​(String id,
                                                           Version version)
        Returns a TouchpointType with the given id and version.
        Parameters:
        id - The touchpoint id
        version - The touchpoint version
        Returns:
        A touchpoint type instance with the given id and version
      • createUpdateDescriptor

        public static IUpdateDescriptor createUpdateDescriptor​(String id,
                                                               VersionRange range,
                                                               int severity,
                                                               String description)
        Creates a new update descriptor object.
        Parameters:
        id - The id of the installable unit that the descriptor provides updates for
        range - The version range that the descriptor provides updates for
        severity - The update severity (either IUpdateDescriptor.NORMAL or IUpdateDescriptor.HIGH)
        description - A description of the update
        Returns:
        A new update descriptor
      • createUpdateDescriptor

        public static IUpdateDescriptor createUpdateDescriptor​(String id,
                                                               VersionRange range,
                                                               int severity,
                                                               String description,
                                                               URI location)
        Create and return a new update descriptor IUpdateDescriptor with the specified values.
        Parameters:
        id - the identifiter for the update. Must not be null.
        range - the version range. A null range is equivalent to VersionRange.emptyRange and matches all versions.
        severity - the severity
        description - a String description or null
        location - a URI specifying the location or null
        Returns:
        the update descriptor