Package com.yahoo.component
Class ComponentId
java.lang.Object
com.yahoo.component.ComponentId
- All Implemented Interfaces:
Comparable<ComponentId>
The id of a component.
Consists of a name, optionally a version, and optionally a namespace.
This is an immutable value object.
- Author:
- bratseth, Tony Vaagenes
-
Constructor Summary
ConstructorDescriptionComponentId
(String id) Creates a component id from the id string form: name(:version)?(@namespace)?, where version has the form 1(.2(.3(.identifier)?)?)? and namespace is a component idComponentId
(String name, Version version) Creates a component id from a name and version.ComponentId
(String name, Version version, ComponentId namespace) -
Method Summary
Modifier and TypeMethodDescriptionint
compareTo
(ComponentId other) static ComponentId
createAnonymousComponentId
(String baseName) Creates a componentId that is unique for this run-time instanceboolean
static ComponentId
fromFileName
(String fileName) Creates an id from a file first name string encoded in the standard translation (seetoFileName()
).static ComponentId
fromString
(String componentId) Creates a component id from the id string form: name(:version)?(@namespace)?, where version has the form 1(.2(.3(.identifier)?)?)? and namespace is a component id.getName()
Returns the name of this.The namespace is null if this is a top level component idReturns the version of this id, or emptyVersion if no version is specifiedint
hashCode()
boolean
nestInNamespace
(ComponentId namespace) static ComponentId
newAnonymous
(String spec) Creates a component id with the given value, marked as anonymousstatic void
WARNING: For testing only: Resets counters creating anonymous component ids for this thread.Returns the string value of this id.Returns this id's stringValue (i.e the id without trailing ".0"'s) translated to a file name using the standard translation:toString()
Returns a copy of this id with namespace set to null
-
Constructor Details
-
ComponentId
Creates a component id from the id string form: name(:version)?(@namespace)?, where version has the form 1(.2(.3(.identifier)?)?)? and namespace is a component id -
ComponentId
-
ComponentId
Creates a component id from a name and version. The version may be null
-
-
Method Details
-
nestInNamespace
-
getName
Returns the name of this. This is never null -
getVersion
Returns the version of this id, or emptyVersion if no version is specified -
getNamespace
The namespace is null if this is a top level component id -
stringValue
Returns the string value of this id. If no version is given, this is simply the name. If a version is given, it is name:version. Trailing ".0"'s are stripped from the version part. -
toString
-
equals
-
hashCode
public int hashCode() -
toSpecification
-
compareTo
- Specified by:
compareTo
in interfaceComparable<ComponentId>
-
createAnonymousComponentId
Creates a componentId that is unique for this run-time instance -
isAnonymous
public boolean isAnonymous() -
withoutNamespace
Returns a copy of this id with namespace set to null -
fromString
Creates a component id from the id string form: name(:version)?(@namespace)?, where version has the form 1(.2(.3(.identifier)?)?)? and namespace is a component id.- Returns:
- new ComponentId(componentId), or null if the input string is null
-
toFileName
Returns this id's stringValue (i.e the id without trailing ".0"'s) translated to a file name using the standard translation:: → - / → _
-
fromFileName
Creates an id from a file first name string encoded in the standard translation (seetoFileName()
). Note that any file last name, like e.g ".xml" must be stripped off before handoff to this method. -
resetGlobalCountersForTests
public static void resetGlobalCountersForTests()WARNING: For testing only: Resets counters creating anonymous component ids for this thread. -
newAnonymous
Creates a component id with the given value, marked as anonymous
-