Package com.yahoo.component
Class ComponentSpecification
- java.lang.Object
-
- com.yahoo.component.ComponentSpecification
-
public final class ComponentSpecification extends java.lang.Object
The specification of a wanted component. Consists of a name, optionally a version specification, and optionally a namespace. This is an immutable value object- Author:
- Arne Bergene Fossaa, Tony Vaagenes
-
-
Constructor Summary
Constructors Constructor Description ComponentSpecification(java.lang.String id)
Creates a component id from the id string form: name(:version?), where version has the form 1(.2(.3(.identifier)?)?)?ComponentSpecification(java.lang.String name, VersionSpecification versionSpec)
Creates a component id from a name and version.ComponentSpecification(java.lang.String name, VersionSpecification versionSpecification, ComponentId namespace)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object o)
static ComponentSpecification
fromString(java.lang.String componentSpecification)
Creates a component id from the id string form: name(:version?), where version has the form 1(.2(.3(.identifier)?)?)?java.lang.String
getName()
Returns the name of this.ComponentId
getNamespace()
The namespace is null if this is to match a top level component idVersionSpecification
getVersionSpecification()
Returns the version of this id, or null if no version is specifiedint
hashCode()
ComponentSpecification
intersect(ComponentSpecification other)
boolean
matches(ComponentId id)
Checks if a componentId matches a given specComponentSpecification
nestInNamespace(ComponentId namespace)
java.lang.String
stringValue()
Returns the string value of this id.ComponentId
toId()
Converts the specification to an idjava.lang.String
toString()
ComponentSpecification
withoutNamespace()
Returns a copy of this spec with namespace set to null
-
-
-
Constructor Detail
-
ComponentSpecification
public ComponentSpecification(java.lang.String name, VersionSpecification versionSpecification, ComponentId namespace)
-
ComponentSpecification
public ComponentSpecification(java.lang.String name, VersionSpecification versionSpec)
Creates a component id from a name and version. The version may be null
-
ComponentSpecification
public ComponentSpecification(java.lang.String id)
Creates a component id from the id string form: name(:version?), where version has the form 1(.2(.3(.identifier)?)?)?
-
-
Method Detail
-
fromString
public static ComponentSpecification fromString(java.lang.String componentSpecification)
Creates a component id from the id string form: name(:version?), where version has the form 1(.2(.3(.identifier)?)?)?- Returns:
- null iff componentSpecification == null
-
nestInNamespace
public ComponentSpecification nestInNamespace(ComponentId namespace)
-
getNamespace
public ComponentId getNamespace()
The namespace is null if this is to match a top level component id
-
getName
public java.lang.String getName()
Returns the name of this. This is never null
-
getVersionSpecification
public VersionSpecification getVersionSpecification()
Returns the version of this id, or null if no version is specified
-
stringValue
public java.lang.String 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
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toId
public ComponentId toId()
Converts the specification to an id
-
matches
public boolean matches(ComponentId id)
Checks if a componentId matches a given spec
-
intersect
public ComponentSpecification intersect(ComponentSpecification other)
-
withoutNamespace
public ComponentSpecification withoutNamespace()
Returns a copy of this spec with namespace set to null
-
-