Package org.apache.ivy.core.module.id
Class ModuleId
- java.lang.Object
-
- org.apache.ivy.core.module.id.ModuleId
-
- All Implemented Interfaces:
java.lang.Comparable<ModuleId>
public class ModuleId extends java.lang.Object implements java.lang.Comparable<ModuleId>
Identifies a module, without revision information- See Also:
- org.apache.ivy.core.module.id
-
-
Field Summary
Fields Modifier and Type Field Description static java.util.regex.PatternMID_PATTERNPattern to use to matched mid text representation.
-
Constructor Summary
Constructors Constructor Description ModuleId(java.lang.String organisation, java.lang.String name)Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description intcompareTo(ModuleId that)static ModuleIddecode(java.lang.String encoded)Returns a ModuleIdjava.lang.StringencodeToString()Returns the encoded String representing this ModuleId.booleanequals(java.lang.Object obj)java.util.Map<java.lang.String,java.lang.String>getAttributes()Returns a Map of all attributes of this module id.java.lang.StringgetName()Returns the name of the module.java.lang.StringgetOrganisation()Returns the name of the organisation.inthashCode()static ModuleIdintern(ModuleId moduleId)Returns an intern instance of a ModuleId equals to the given ModuleId if any, or the given ModuleId.static ModuleIdnewInstance(java.lang.String org, java.lang.String name)Returns a ModuleId for the given organization and module name.static ModuleIdparse(java.lang.String mid)Parses the module id text representation and returns it as aModuleIdinstance.java.lang.StringtoString()
-
-
-
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)
-
-
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 benullname- the module's name, must not benull- 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:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
compareTo
public int compareTo(ModuleId that)
- Specified by:
compareToin interfacejava.lang.Comparable<ModuleId>
-
encodeToString
public java.lang.String encodeToString()
Returns the encoded String representing this ModuleId.- Returns:
- The ModuleId encoded as String.
-
getAttributes
public java.util.Map<java.lang.String,java.lang.String> 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- String- 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 aModuleIdinstance.- 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
-
-