Class 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 Detail

      • 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
      • 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.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class 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
      • withoutNamespace

        public ComponentSpecification withoutNamespace()
        Returns a copy of this spec with namespace set to null