Search in sources :

Example 11 with VersionNumber

use of org.eclipse.n4js.semver.Semver.VersionNumber in project n4js by eclipse.

the class VersionTest method testCompareWithQualifier.

@Test
public void testCompareWithQualifier() {
    VersionNumber lower = version(1, 2, 3, "alpha", null);
    VersionNumber greater = version(1, 2, 3, "beta", null);
    VersionNumber greatest = version(1, 2, 3);
    RelationKind relationKind = RelationKind.SemverMatchAllowPrereleaseTags;
    Assert.assertEquals(VersionNumberRelation.Equal, SemverMatcher.relation(lower, lower, relationKind));
    Assert.assertEquals(VersionNumberRelation.Smaller, SemverMatcher.relation(lower, greater, relationKind));
    Assert.assertEquals(VersionNumberRelation.Smaller, SemverMatcher.relation(lower, greatest, relationKind));
    Assert.assertEquals(VersionNumberRelation.Greater, SemverMatcher.relation(greater, lower, relationKind));
    Assert.assertEquals(VersionNumberRelation.Equal, SemverMatcher.relation(greater, greater, relationKind));
    Assert.assertEquals(VersionNumberRelation.Smaller, SemverMatcher.relation(greater, greatest, relationKind));
    Assert.assertEquals(VersionNumberRelation.Greater, SemverMatcher.relation(greatest, lower, relationKind));
    Assert.assertEquals(VersionNumberRelation.Greater, SemverMatcher.relation(greatest, greater, relationKind));
    Assert.assertEquals(VersionNumberRelation.Equal, SemverMatcher.relation(greatest, greatest, relationKind));
}
Also used : RelationKind(org.eclipse.n4js.semver.SemverMatcher.RelationKind) VersionNumber(org.eclipse.n4js.semver.Semver.VersionNumber) Test(org.junit.Test)

Example 12 with VersionNumber

use of org.eclipse.n4js.semver.Semver.VersionNumber in project n4js by eclipse.

the class HyphenVersionRangeImpl method basicSetTo.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public NotificationChain basicSetTo(VersionNumber newTo, NotificationChain msgs) {
    VersionNumber oldTo = to;
    to = newTo;
    if (eNotificationRequired()) {
        ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, SemverPackage.HYPHEN_VERSION_RANGE__TO, oldTo, newTo);
        if (msgs == null)
            msgs = notification;
        else
            msgs.add(notification);
    }
    return msgs;
}
Also used : ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl) VersionNumber(org.eclipse.n4js.semver.Semver.VersionNumber)

Example 13 with VersionNumber

use of org.eclipse.n4js.semver.Semver.VersionNumber in project n4js by eclipse.

the class VersionNumberImpl method equals.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public boolean equals(final Object obj) {
    if ((!(obj instanceof VersionNumber))) {
        return false;
    }
    final VersionNumber vn = ((VersionNumber) obj);
    boolean equals = true;
    int _length = this.length();
    int _length_1 = vn.length();
    boolean _equals = (_length == _length_1);
    equals = _equals;
    for (int i = 0; (i < this.length()); i++) {
        equals = (equals && this.getPart(i).equals(vn.getPart(i)));
    }
    equals = (equals && (Boolean.valueOf((this.getQualifier() == null)) == Boolean.valueOf((vn.getQualifier() == null))));
    equals = (equals && ((this.getQualifier() == null) || this.getQualifier().equals(vn.getQualifier())));
    return equals;
}
Also used : VersionNumber(org.eclipse.n4js.semver.Semver.VersionNumber)

Example 14 with VersionNumber

use of org.eclipse.n4js.semver.Semver.VersionNumber in project n4js by eclipse.

the class SemverConverter method simplifyCaret.

private static List<SimpleVersion> simplifyCaret(SimpleVersion sv) {
    VersionNumber caretVN = sv.getNumber();
    VersionNumberDescriptor vnd = SemverUtils.getVersionNumberDescriptor(caretVN);
    VersionNumberDescriptor vndCaretUpper = vnd.getCaretUpperBound();
    return packRange(vnd, VersionComparator.GREATER_EQUALS, vndCaretUpper, VersionComparator.SMALLER);
}
Also used : VersionNumberDescriptor(org.eclipse.n4js.semver.SemverUtils.VersionNumberDescriptor) VersionNumber(org.eclipse.n4js.semver.Semver.VersionNumber)

Example 15 with VersionNumber

use of org.eclipse.n4js.semver.Semver.VersionNumber in project n4js by eclipse.

the class SemverConverter method packRange.

private static List<SimpleVersion> packRange(VersionNumberDescriptor vndFrom, VersionComparator vcFrom, VersionNumberDescriptor vndTo, VersionComparator vcTo) {
    VersionNumber vnFrom = SemverUtils.createVersionNumber(vndFrom);
    VersionNumber vnTo = SemverUtils.createVersionNumber(vndTo);
    SimpleVersion svFrom = SemverFactory.eINSTANCE.createSimpleVersion();
    SimpleVersion svTo = SemverFactory.eINSTANCE.createSimpleVersion();
    svFrom.getComparators().add(vcFrom);
    svTo.getComparators().add(vcTo);
    svFrom.setNumber(vnFrom);
    svTo.setNumber(vnTo);
    return Lists.newArrayList(svFrom, svTo);
}
Also used : SimpleVersion(org.eclipse.n4js.semver.Semver.SimpleVersion) VersionNumber(org.eclipse.n4js.semver.Semver.VersionNumber)

Aggregations

VersionNumber (org.eclipse.n4js.semver.Semver.VersionNumber)19 SimpleVersion (org.eclipse.n4js.semver.Semver.SimpleVersion)4 VersionRangeConstraint (org.eclipse.n4js.semver.Semver.VersionRangeConstraint)4 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)3 VersionNumberDescriptor (org.eclipse.n4js.semver.SemverUtils.VersionNumberDescriptor)3 Qualifier (org.eclipse.n4js.semver.Semver.Qualifier)2 QualifierTag (org.eclipse.n4js.semver.Semver.QualifierTag)2 VersionPart (org.eclipse.n4js.semver.Semver.VersionPart)2 VersionRangeSetRequirement (org.eclipse.n4js.semver.Semver.VersionRangeSetRequirement)2 ArrayList (java.util.ArrayList)1 EPackage (org.eclipse.emf.ecore.EPackage)1 NameValuePair (org.eclipse.n4js.json.JSON.NameValuePair)1 ProjectDescription (org.eclipse.n4js.packagejson.projectDescription.ProjectDescription)1 SourceContainerDescription (org.eclipse.n4js.packagejson.projectDescription.SourceContainerDescription)1 GitHubVersionRequirement (org.eclipse.n4js.semver.Semver.GitHubVersionRequirement)1 HyphenVersionRange (org.eclipse.n4js.semver.Semver.HyphenVersionRange)1 LocalPathVersionRequirement (org.eclipse.n4js.semver.Semver.LocalPathVersionRequirement)1 TagVersionRequirement (org.eclipse.n4js.semver.Semver.TagVersionRequirement)1 URLCommitISH (org.eclipse.n4js.semver.Semver.URLCommitISH)1 URLSemver (org.eclipse.n4js.semver.Semver.URLSemver)1