ModuleId
Date: 2014-12-13

org.apache.ivy.core.module.id

## Class ModuleId

- java.lang.Object
- - org.apache.ivy.core.module.id.ModuleId

- All Implemented Interfaces:
    java.lang.Comparable

      public class ModuleId
      extends java.lang.Object
      implements java.lang.Comparable

  Identifies a module, without revision information
  See Also:
    org.apache.ivy.core.module.id

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static java.util.regex.Pattern` | `MID_PATTERN` Pattern to use to matched mid text representation.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ModuleId(java.lang.String organisation, java.lang.String name)` Constructor.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `int` | `compareTo(java.lang.Object obj)`
    `static ModuleId` | `decode(java.lang.String encoded)` Returns a ModuleId
    `java.lang.String` | `encodeToString()` Returns the encoded String representing this ModuleId.
    `boolean` | `equals(java.lang.Object obj)`
    `java.util.Map` | `getAttributes()` Returns a Map of all attributes of this module id.
    `java.lang.String` | `getName()` Returns the name of the module.
    `java.lang.String` | `getOrganisation()` Returns the name of the organisation.
    `int` | `hashCode()`
    `static ModuleId` | `intern(ModuleId moduleId)` Returns an intern instance of a ModuleId equals to the given ModuleId if any, or the given ModuleId.
    `static ModuleId` | `newInstance(java.lang.String org, java.lang.String name)` Returns a ModuleId for the given organization and module name.
    `static ModuleId` | `parse(java.lang.String mid)` Parses the module id text representation and returns it as a `ModuleId` instance.
    `java.lang.String` | `toString()`

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

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

- - ### Field Detail

    - #### MID_PATTERN

          public static final java.util.regex.Pattern MID_PATTERN

      Pattern to use to matched mid text representation.
      See Also:
        `parse(String)`

  - ### Constructor Detail

    - #### ModuleId

          public ModuleId(java.lang.String organisation,
                  java.lang.String name)

      Constructor.
      Parameters:
        `organisation` - The organisation which creates the module.
        `name` - The name of the module.

  - ### Method Detail

    - #### newInstance

          public static ModuleId newInstance(java.lang.String org,
                             java.lang.String name)

      Returns a ModuleId for the given organization and module name.
      Parameters:
        `org` - the module's organization, can be `null`
        `name` - the module's name, must not be `null`
      Returns:
        a ModuleId instance

    - #### intern

          public static ModuleId intern(ModuleId moduleId)

      Returns an intern instance of a ModuleId equals to the given ModuleId if any, or the given ModuleId.

      This is useful to reduce the number of instances of ModuleId kept in memory, and thus reduce memory footprint.

      Parameters:
        `moduleId` - the module id to return
      Returns:
        a unit instance of the given module id.

    - #### getName

          public java.lang.String getName()

      Returns the name of the module.
      Returns:
        The name of the module.

    - #### getOrganisation

          public java.lang.String getOrganisation()

      Returns the name of the organisation.
      Returns:
        The name of the organisation.

    - #### equals

          public boolean equals(java.lang.Object obj)

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

    - #### hashCode

          public int hashCode()

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

    - #### toString

          public java.lang.String toString()

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

    - #### compareTo

          public int compareTo(java.lang.Object obj)

      Specified by:
        `compareTo` in interface `java.lang.Comparable`

    - #### encodeToString

          public java.lang.String encodeToString()

      Returns the encoded String representing this ModuleId.
      Returns:
        The ModuleId encoded as String.

    - #### getAttributes

          public java.util.Map getAttributes()

      Returns a Map of all attributes of this module id. The Map keys are attribute names as Strings, and values are corresponding attribute values (as String too).
      Returns:
        A Map instance containing all the attributes and their values.

    - #### decode

          public static ModuleId decode(java.lang.String encoded)

      Returns a ModuleId
      Parameters:
        `encoded` -
      Returns:
        The new ModuleId.
      Throws:
        `java.lang.IllegalArgumentException` - If the given String could not be decoded.

    - #### parse

          public static ModuleId parse(java.lang.String mid)

      Parses the module id text representation and returns it as a `ModuleId` instance.
      Parameters:
        `mid` - the module id text representation to parse
      Returns:
        the ModuleId instance corresponding to the representation
      Throws:
        `java.lang.IllegalArgumentException` - if the given text representation cannot be parsed