• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

devonfw / IDEasy / 7263768820

19 Dec 2023 03:13PM UTC coverage: 49.404% (+1.5%) from 47.873%
7263768820

Pull #159

github

web-flow
Merge e50749a62 into 1d60d9c17
Pull Request #159: #158: VersionRange with open boundaries

1127 of 2459 branches covered (0.0%)

Branch coverage included in aggregate %.

2812 of 5514 relevant lines covered (51.0%)

2.11 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

33.33
cli/src/main/java/com/devonfw/tools/ide/version/VersionObject.java
1
package com.devonfw.tools.ide.version;
2

3
/**
4
 * Abstract base interface for a version object such as {@link VersionIdentifier} and {@link VersionSegment}.
5
 *
6
 * {@link Comparable} for versions with an extended contract. If two versions are not strictly comparable (e.g.
7
 * "1.apple" and "1.banana") we fall back to some heuristics (e.g. lexicographical comparison for
8
 * {@link VersionSegment#getLettersString() letters} that we do not understand (e.g. "apple" < "banana"). Therefore, you
9
 * can use {@link #compareVersion(Object)} to get a {@link VersionComparisonResult} that contains the additional
10
 * information as {@link VersionComparisonResult#isUnsafe() unsafe} flag.
11
 *
12
 * @param <T> type of the object to compare (this class itself).
13
 */
14
public interface VersionObject<T> extends Comparable<T> {
15

16
  @Override
17
  default int compareTo(T other) {
18

19
    return compareVersion(other).asValue();
5✔
20
  }
21

22
  /**
23
   * @param other the other version to compare to.
24
   * @return the {@link VersionComparisonResult}.
25
   */
26
  VersionComparisonResult compareVersion(T other);
27

28
  /**
29
   * @param other the other version to compare to.
30
   * @return true if this version is greater than the given one.
31
   */
32
  default boolean isGreater(T other) {
33

34
    return compareVersion(other).isGreater();
5✔
35
  }
36

37
  /**
38
   * @param other the other version to compare to.
39
   * @return true if this version is less than the given one.
40
   */
41
  default boolean isLess(T other) {
42

43
    return compareVersion(other).isLess();
5✔
44
  }
45

46
  /**
47
   * @param other the other version to compare to.
48
   * @return true if this version is greater than or equal to the given one.
49
   */
50
  default boolean isGreaterOrEqual(T other) {
51

52
    return !compareVersion(other).isLess();
×
53
  }
54

55
  /**
56
   * @param other the other version to compare to.
57
   * @return true if this version is less than or equal to the given one.
58
   */
59
  default boolean isLessOrEqual(T other) {
60

61
    return !compareVersion(other).isGreater();
×
62
  }
63

64
  /**
65
   * @return {@code true} if this {@link VersionObject} itself is valid according to version scheme best-practices,
66
   *         {@code false} otherwise. Invalid {@link VersionObject}s can still be parsed and compared in a deterministic
67
   *         way but results may not always be perfect.
68
   */
69
  boolean isValid();
70

71
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc