public int compareTo(Spec<VERSION> other) { int result = name.compareTo(other.name); if (result != 0) return result; result = versionHandler.compare(version, other.version); if (result != 0) return result; return compare(namespace, other.namespace); }
String createStringValue() { if (isNonEmpty(version) || (namespace != null)) { StringBuilder builder = new StringBuilder(name); if (isNonEmpty(version)) builder.append(':').append(version); if (namespace != null) builder.append('@').append(namespace.stringValue()); return builder.toString(); } else { return name; } }
@Override public String toString() { return spec.toString(); }
public ComponentSpecification(String name, VersionSpecification versionSpecification, ComponentId namespace) { spec = new Spec<>(new VersionHandler(), name, versionSpecification, namespace); stringValue = spec.createStringValue(); }
@SuppressWarnings("unchecked") Spec(VersionHandler<VERSION> versionHandler, String name, VERSION version, ComponentId namespace) { assert (name != null); validateName(name); this.versionHandler = versionHandler; this.name = name; this.version = firstNonNull(version, versionHandler.emptyVersion()); this.namespace = namespace; }
public int compareTo(ComponentId other) { //anonymous must never be equal to non-anonymous if (isAnonymous() ^ other.isAnonymous()) { return isAnonymous() ? -1 : 1; } return spec.compareTo(other.spec); }
private ComponentId(String name, Version version, ComponentId namespace, boolean anonymous) { if (anonymous) { name = createAnonymousName(name); } spec = new Spec<>(new VersionHandler(), name, version, namespace); this.anonymous = anonymous; stringValue = spec.createStringValue(); }
@Override public String toString() { if (isNonEmpty(version) || (namespace != null)) { StringBuilder builder = new StringBuilder(name); if (isNonEmpty(version)) { builder.append(':').append(version); } if (namespace != null) { builder.append(" in ").append(namespace.toString()); } return builder.toString(); } else { return name; } }