Package com.yahoo.component
Class ComponentSpecification
- java.lang.Object
-
- com.yahoo.component.ComponentSpecification
-
public final class ComponentSpecification extends 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(String id)
Creates a component id from the id string form: name(:version?), where version has the form 1(.2(.3(.identifier)?)?)?ComponentSpecification(String name, VersionSpecification versionSpec)
Creates a component id from a name and version.ComponentSpecification(String name, VersionSpecification versionSpecification, ComponentId namespace)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object o)
static ComponentSpecification
fromString(String componentSpecification)
Creates a component id from the id string form: name(:version?), where version has the form 1(.2(.3(.identifier)?)?)?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)
String
stringValue()
Returns the string value of this id.ComponentId
toId()
Converts the specification to an idString
toString()
ComponentSpecification
withoutNamespace()
Returns a copy of this spec with namespace set to null
-
-
-
Constructor Detail
-
ComponentSpecification
public ComponentSpecification(String name, VersionSpecification versionSpecification, ComponentId namespace)
-
ComponentSpecification
public ComponentSpecification(String name, VersionSpecification versionSpec)
Creates a component id from a name and version. The version may be null
-
ComponentSpecification
public ComponentSpecification(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(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 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 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.
-
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
-
-