DefaultDependencyDescriptor
Date: 2014-12-13

org.apache.ivy.core.module.descriptor

## Class DefaultDependencyDescriptor

- java.lang.Object
- - org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor

- All Implemented Interfaces:
    DependencyDescriptor, InheritableItem, ExtendableItem
  Direct Known Subclasses:
    PomModuleDescriptorBuilder.PomDependencyDescriptor

      public class DefaultDependencyDescriptor
      extends java.lang.Object
      implements DependencyDescriptor

  This class can be used as the default implementation for DependencyDescriptor. It implements required methods and enables to fill dependency information with the addDependencyConfiguration method.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `DefaultDependencyDescriptor(ModuleDescriptor md, ModuleRevisionId mrid, boolean force, boolean changing, boolean transitive)`
    `DefaultDependencyDescriptor(ModuleDescriptor md, ModuleRevisionId mrid, ModuleRevisionId dynamicConstraint, boolean force, boolean changing, boolean transitive)`
    `DefaultDependencyDescriptor(ModuleRevisionId mrid, boolean force)`
    `DefaultDependencyDescriptor(ModuleRevisionId mrid, boolean force, boolean changing)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addDependencyArtifact(java.lang.String masterConf, DependencyArtifactDescriptor dad)`
    `void` | `addDependencyConfiguration(java.lang.String masterConf, java.lang.String depConf)`
    `void` | `addExcludeRule(java.lang.String masterConf, ExcludeRule rule)`
    `void` | `addIncludeRule(java.lang.String masterConf, IncludeRule rule)`
    `DependencyDescriptor` | `asSystem()`
    `boolean` | `canExclude()` Returns true if this descriptor contains any exclusion rule
    `DependencyDescriptor` | `clone(ModuleRevisionId revision)` Clones current dependency descriptor with another revision.
    `boolean` | `doesExclude(java.lang.String[] moduleConfigurations, ArtifactId artifactId)` only works when namespace is properly set.
    `DependencyArtifactDescriptor[]` | `getAllDependencyArtifacts()`
    `ExcludeRule[]` | `getAllExcludeRules()`
    `IncludeRule[]` | `getAllIncludeRules()`
    `java.lang.String` | `getAttribute(java.lang.String attName)` Gets the value of an attribute Can be used to access the value of a standard attribute (like organisation, revision) or of an extra attribute.
    `java.util.Map` | `getAttributes()` Returns a Map of all attributes of this extendable item, including standard and extra ones.
    `DependencyArtifactDescriptor[]` | `getDependencyArtifacts(java.lang.String moduleConfiguration)`
    `DependencyArtifactDescriptor[]` | `getDependencyArtifacts(java.lang.String[] moduleConfigurations)`
    `java.lang.String[]` | `getDependencyConfigurations(java.lang.String moduleConfiguration)`
    `java.lang.String[]` | `getDependencyConfigurations(java.lang.String[] moduleConfigurations)`
    `java.lang.String[]` | `getDependencyConfigurations(java.lang.String moduleConfiguration, java.lang.String requestedConfiguration)` Return the dependency configurations mapped to the given moduleConfiguration, actually resolved because of the given requestedConfiguration Usually requestedConfiguration and moduleConfiguration are the same, except when a conf extends another, then the moduleConfiguration is the configuration currently resolved (the extended one), and requestedConfiguration is the one actually requested initially (the extending one).
    `ModuleId` | `getDependencyId()`
    `ModuleRevisionId` | `getDependencyRevisionId()` Returns the constraint on dependency this descriptor represents.
    `ModuleRevisionId` | `getDynamicConstraintDependencyRevisionId()` Returns the dynamic constraint on dependency this descriptor represents.
    `ExcludeRule[]` | `getExcludeRules(java.lang.String moduleConfiguration)`
    `ExcludeRule[]` | `getExcludeRules(java.lang.String[] moduleConfigurations)`
    `java.lang.String` | `getExtraAttribute(java.lang.String attName)` Gets the value of an extra attribute Can be used only to access the value of an extra attribute, not a standard one (like organisation, revision)
    `java.util.Map` | `getExtraAttributes()` Returns a Map of all extra attributes of this extendable item.
    `IncludeRule[]` | `getIncludeRules(java.lang.String moduleConfiguration)`
    `IncludeRule[]` | `getIncludeRules(java.lang.String[] moduleConfigurations)`
    `java.lang.String[]` | `getModuleConfigurations()`
    `Namespace` | `getNamespace()`
    `ModuleRevisionId` | `getParentRevisionId()`
    `java.util.Map` | `getQualifiedExtraAttributes()` Returns a Map of all extra attributes of this extendable item.
    `ModuleRevisionId` | `getSourceModule()`
    `boolean` | `isChanging()` Used to indicate that this dependency is a changing one.
    `boolean` | `isForce()` Used to indicate that this revision must be used in case of conflicts, independently of conflicts manager.
    `boolean` | `isTransitive()`
    `protected static java.lang.String` | `replaceFallbackConfigurationPattern(java.util.regex.Pattern pattern, java.lang.String conf, java.lang.String moduleConfiguration)` Replaces fallback patterns with correct values if fallback pattern exists.
    `protected static java.lang.String` | `replaceSelfFallbackPattern(java.lang.String conf, java.lang.String moduleConfiguration)`
    `protected static java.lang.String` | `replaceThisFallbackPattern(java.lang.String conf, java.lang.String requestedConfiguration)`
    `java.lang.String` | `toString()`
    `static DependencyDescriptor` | `transformInstance(DependencyDescriptor dd, Namespace ns)` Transforms the given dependency descriptor of the given namespace and return a new dependency descriptor in the system namespace.
    `static DefaultDependencyDescriptor` | `transformInstance(DependencyDescriptor dd, NamespaceTransformer t, boolean fromSystem)` Transforms a dependency descriptor using the given transformer.

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

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

- - ### Constructor Detail

    - #### DefaultDependencyDescriptor

          public DefaultDependencyDescriptor(ModuleDescriptor md,
                                     ModuleRevisionId mrid,
                                     boolean force,
                                     boolean changing,
                                     boolean transitive)

    - #### DefaultDependencyDescriptor

          public DefaultDependencyDescriptor(ModuleRevisionId mrid,
                                     boolean force)

    - #### DefaultDependencyDescriptor

          public DefaultDependencyDescriptor(ModuleRevisionId mrid,
                                     boolean force,
                                     boolean changing)

    - #### DefaultDependencyDescriptor

          public DefaultDependencyDescriptor(ModuleDescriptor md,
                                     ModuleRevisionId mrid,
                                     ModuleRevisionId dynamicConstraint,
                                     boolean force,
                                     boolean changing,
                                     boolean transitive)

  - ### Method Detail

    - #### transformInstance

          public static DependencyDescriptor transformInstance(DependencyDescriptor dd,
                                               Namespace ns)

      Transforms the given dependency descriptor of the given namespace and return a new dependency descriptor in the system namespace. Note that exclude rules are not converted in system namespace, because they aren't transformable (the name space hasn't the ability to convert regular expressions). However, method doesExclude will work with system artifacts.
      Parameters:
        `dd` -
        `ns` -
      Returns:

    - #### transformInstance

          public static DefaultDependencyDescriptor transformInstance(DependencyDescriptor dd,
                                                      NamespaceTransformer t,
                                                      boolean fromSystem)

      Transforms a dependency descriptor using the given transformer. Note that no namespace info will be attached to the transformed dependency descriptor, so calling doesExclude is not recommended (doesExclude only works when namespace is properly set)
      Parameters:
        `dd` -
        `t` -
      Returns:

    - #### getDependencyId

          public ModuleId getDependencyId()

      Specified by:
        `getDependencyId` in interface `DependencyDescriptor`

    - #### getDependencyRevisionId

          public ModuleRevisionId getDependencyRevisionId()

      Description copied from interface: `DependencyDescriptor`
      Returns the constraint on dependency this descriptor represents.
      Specified by:
        `getDependencyRevisionId` in interface `DependencyDescriptor`
      Returns:
        the constraint on dependency.

    - #### getDynamicConstraintDependencyRevisionId

          public ModuleRevisionId getDynamicConstraintDependencyRevisionId()

      Description copied from interface: `DependencyDescriptor`
      Returns the dynamic constraint on dependency this descriptor represents.
      Specified by:
        `getDynamicConstraintDependencyRevisionId` in interface `DependencyDescriptor`
      Returns:
        the dynamic constraint on dependency, or exact constraint if no dynamic constraint is specified.

    - #### getModuleConfigurations

          public java.lang.String[] getModuleConfigurations()

      Specified by:
        `getModuleConfigurations` in interface `DependencyDescriptor`

    - #### getDependencyConfigurations

          public java.lang.String[] getDependencyConfigurations(java.lang.String moduleConfiguration)

      Specified by:
        `getDependencyConfigurations` in interface `DependencyDescriptor`

    - #### getDependencyConfigurations

          public java.lang.String[] getDependencyConfigurations(java.lang.String moduleConfiguration,
                                                       java.lang.String requestedConfiguration)

      Return the dependency configurations mapped to the given moduleConfiguration, actually resolved because of the given requestedConfiguration

      Usually requestedConfiguration and moduleConfiguration are the same, except when a conf extends another, then the moduleConfiguration is the configuration currently resolved (the extended one), and requestedConfiguration is the one actually requested initially (the extending one). Both moduleConfiguration and requestedConfiguration are configurations of the caller, the array returned is composed of the required configurations of the dependency described by this descriptor.

      Specified by:
        `getDependencyConfigurations` in interface `DependencyDescriptor`

    - #### replaceSelfFallbackPattern

          protected static java.lang.String replaceSelfFallbackPattern(java.lang.String conf,
                                                    java.lang.String moduleConfiguration)

    - #### replaceThisFallbackPattern

          protected static java.lang.String replaceThisFallbackPattern(java.lang.String conf,
                                                    java.lang.String requestedConfiguration)

    - #### replaceFallbackConfigurationPattern

          protected static java.lang.String replaceFallbackConfigurationPattern(java.util.regex.Pattern pattern,
                                                             java.lang.String conf,
                                                             java.lang.String moduleConfiguration)

      Replaces fallback patterns with correct values if fallback pattern exists.
      Parameters:
        `pattern` - pattern to look for
        `conf` - configuration mapping from dependency element
        `moduleConfiguration` - module's configuration to use for replacement
      Returns:
        Replaced string if pattern matched. Otherwise null.

    - #### getDependencyConfigurations

          public java.lang.String[] getDependencyConfigurations(java.lang.String[] moduleConfigurations)

      Specified by:
        `getDependencyConfigurations` in interface `DependencyDescriptor`

    - #### getDependencyArtifacts

          public DependencyArtifactDescriptor[] getDependencyArtifacts(java.lang.String moduleConfiguration)

      Specified by:
        `getDependencyArtifacts` in interface `DependencyDescriptor`

    - #### getIncludeRules

          public IncludeRule[] getIncludeRules(java.lang.String moduleConfiguration)

      Specified by:
        `getIncludeRules` in interface `DependencyDescriptor`

    - #### getExcludeRules

          public ExcludeRule[] getExcludeRules(java.lang.String moduleConfiguration)

      Specified by:
        `getExcludeRules` in interface `DependencyDescriptor`

    - #### getDependencyArtifacts

          public DependencyArtifactDescriptor[] getDependencyArtifacts(java.lang.String[] moduleConfigurations)

      Specified by:
        `getDependencyArtifacts` in interface `DependencyDescriptor`

    - #### getIncludeRules

          public IncludeRule[] getIncludeRules(java.lang.String[] moduleConfigurations)

      Specified by:
        `getIncludeRules` in interface `DependencyDescriptor`

    - #### getExcludeRules

          public ExcludeRule[] getExcludeRules(java.lang.String[] moduleConfigurations)

      Specified by:
        `getExcludeRules` in interface `DependencyDescriptor`

    - #### getAllDependencyArtifacts

          public DependencyArtifactDescriptor[] getAllDependencyArtifacts()

      Specified by:
        `getAllDependencyArtifacts` in interface `DependencyDescriptor`

    - #### getAllIncludeRules

          public IncludeRule[] getAllIncludeRules()

      Specified by:
        `getAllIncludeRules` in interface `DependencyDescriptor`

    - #### getAllExcludeRules

          public ExcludeRule[] getAllExcludeRules()

      Specified by:
        `getAllExcludeRules` in interface `DependencyDescriptor`

    - #### addDependencyConfiguration

          public void addDependencyConfiguration(java.lang.String masterConf,
                                        java.lang.String depConf)

    - #### addDependencyArtifact

          public void addDependencyArtifact(java.lang.String masterConf,
                                   DependencyArtifactDescriptor dad)

    - #### addIncludeRule

          public void addIncludeRule(java.lang.String masterConf,
                            IncludeRule rule)

    - #### addExcludeRule

          public void addExcludeRule(java.lang.String masterConf,
                            ExcludeRule rule)

    - #### doesExclude

          public boolean doesExclude(java.lang.String[] moduleConfigurations,
                            ArtifactId artifactId)

      only works when namespace is properly set. The behaviour is not specified if namespace is not set
      Specified by:
        `doesExclude` in interface `DependencyDescriptor`
      Returns:

    - #### canExclude

          public boolean canExclude()

      Returns true if this descriptor contains any exclusion rule
      Specified by:
        `canExclude` in interface `DependencyDescriptor`
      Returns:

    - #### toString

          public java.lang.String toString()

      Overrides:
        `toString` in class `java.lang.Object`

    - #### isForce

          public boolean isForce()

      Description copied from interface: `DependencyDescriptor`
      Used to indicate that this revision must be used in case of conflicts, independently of conflicts manager. This only works for direct dependencies, and not transitive ones.
      Specified by:
        `isForce` in interface `DependencyDescriptor`
      Returns:
        true if this dependency should be used, false if conflicts manager can do its work.

    - #### getParentRevisionId

          public ModuleRevisionId getParentRevisionId()

      Specified by:
        `getParentRevisionId` in interface `DependencyDescriptor`

    - #### isChanging

          public boolean isChanging()

      Description copied from interface: `DependencyDescriptor`
      Used to indicate that this dependency is a changing one. A changing dependency in ivy means that the revision may have its artifacts modified without revision change. When new artifacts are published a new ivy file should also be published with a new publication date to indicate to ivy that artifacts have changed and that they should be downloaded again.
      Specified by:
        `isChanging` in interface `DependencyDescriptor`
      Returns:
        true if this dependency is a changing one

    - #### isTransitive

          public boolean isTransitive()

      Specified by:
        `isTransitive` in interface `DependencyDescriptor`

    - #### getNamespace

          public Namespace getNamespace()

      Specified by:
        `getNamespace` in interface `DependencyDescriptor`

    - #### getAttribute

          public java.lang.String getAttribute(java.lang.String attName)

      Description copied from interface: `ExtendableItem`
      Gets the value of an attribute Can be used to access the value of a standard attribute (like organisation, revision) or of an extra attribute.
      Specified by:
        `getAttribute` in interface `ExtendableItem`
      Parameters:
        `attName` - the name of the attribute to get
      Returns:
        the value of the attribute, null if the attribute doesn't exist

    - #### getAttributes

          public java.util.Map getAttributes()

      Description copied from interface: `ExtendableItem`
      Returns a Map of all attributes of this extendable item, including standard and extra ones. The Map keys are attribute names as Strings, and values are corresponding attribute values (as String too). Extra attributes are included in unqualified form only.
      Specified by:
        `getAttributes` in interface `ExtendableItem`
      Returns:
        A Map instance containing all the attributes and their values.

    - #### getExtraAttribute

          public java.lang.String getExtraAttribute(java.lang.String attName)

      Description copied from interface: `ExtendableItem`
      Gets the value of an extra attribute Can be used only to access the value of an extra attribute, not a standard one (like organisation, revision)
      Specified by:
        `getExtraAttribute` in interface `ExtendableItem`
      Parameters:
        `attName` - the name of the extra attribute to get. This name can be either qualified or unqualified.
      Returns:
        the value of the attribute, null if the attribute doesn't exist

    - #### getExtraAttributes

          public java.util.Map getExtraAttributes()

      Description copied from interface: `ExtendableItem`
      Returns a Map of all extra attributes of this extendable item. The Map keys are unqualified attribute names as Strings, and values are corresponding attribute values (as String too)
      Specified by:
        `getExtraAttributes` in interface `ExtendableItem`
      Returns:
        A Map instance containing all the extra attributes and their values.
      See Also:
        `ExtendableItem.getQualifiedExtraAttributes()`

    - #### getQualifiedExtraAttributes

          public java.util.Map getQualifiedExtraAttributes()

      Description copied from interface: `ExtendableItem`
      Returns a Map of all extra attributes of this extendable item.

      The Map keys are qualified attribute names as Strings, and values are corresponding attribute values (as String too).

      An attribute name is qualified with a namespace exactly the same way xml attributes are qualified. Thus qualified attribute names are of the form `prefix:name`

      Specified by:
        `getQualifiedExtraAttributes` in interface `ExtendableItem`
      Returns:
        A Map instance containing all the extra attributes and their values.
      See Also:
        `ExtendableItem.getExtraAttributes()`

    - #### asSystem

          public DependencyDescriptor asSystem()

      Specified by:
        `asSystem` in interface `DependencyDescriptor`

    - #### getSourceModule

          public ModuleRevisionId getSourceModule()

      Specified by:
        `getSourceModule` in interface `InheritableItem`
      Returns:
        the module in which this item was actually defined, if different from the module in which the item appears. May be null.

    - #### clone

          public DependencyDescriptor clone(ModuleRevisionId revision)

      Description copied from interface: `DependencyDescriptor`
      Clones current dependency descriptor with another revision.
      Specified by:
        `clone` in interface `DependencyDescriptor`
      Parameters:
        `revision` - the revision of the cloned dependency descriptor
      Returns:
        the cloned dependency descriptor