private void assertNoInnerComponents(ChainSpecification specWithoutInnerComponents) { for (ComponentSpecification component : specWithoutInnerComponents.componentReferences) { assert (component.getNamespace() == null); } }
private boolean namespaceMatch(ComponentId otherNamespace) { if (getNamespace() == otherNamespace) { return true; } else if (getNamespace() == null || otherNamespace == null){ return false; } else { return getNamespace().equals(otherNamespace); } }
public ComponentSpecification nestInNamespace(ComponentId namespace) { ComponentId newNameSpace = (getNamespace() == null) ? namespace : getNamespace().nestInNamespace(namespace); return new ComponentSpecification(getName(), getVersionSpecification(), newNameSpace); }
/** * Returns a component. If the id does not specify an (exact) version, the newest (matching) version is returned. * For example, if version 3.1 is specified and we have 3.1.0, 3.1.1 and 3.1.3 registered, 3.1.3 is returned. * * @param id the id of the component to return. May not include a version, or include * an underspecified version, in which case the highest (matching) version which * does not contain a qualifier is returned * @return the search chain or null if no component of this name (and matching version, if specified) is registered */ public COMPONENT getComponent(ComponentSpecification id) { Map<String, Map<Version, COMPONENT>> componentVersionsByName = componentsByNameByNamespace.get(id.getNamespace()); if (componentVersionsByName == null) return null; // No matching namespace Map<Version, COMPONENT> versions = componentVersionsByName.get(id.getName()); if (versions==null) return null; // No versions of this component Version version=findBestMatch(id.getVersionSpecification(), versions.keySet()); //if (version==null) return null; // No matching version return versions.get(version); }
public ComponentSpecification intersect(ComponentSpecification other) { if (!getName().equals(other.getName())) { throw new RuntimeException("The names of the component specifications does not match(" + getName() + "!=" + other.getName() + ")."); } if (!namespaceMatch(other.getNamespace())) { throw new RuntimeException("The namespaces of the component specifications does not match(" + this + ", " + other +")"); } return new ComponentSpecification(getName(), getVersionSpecification().intersect(other.getVersionSpecification()), getNamespace()); }
/** Converts the specification to an id */ public ComponentId toId() { Version version = (getVersionSpecification() == VersionSpecification.emptyVersionSpecification) ? Version.emptyVersion : getVersionSpecification().lowestMatchingVersion(); return new ComponentId(getName(), version, getNamespace()); }