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

devonfw / IDEasy / 38742671777

15 Oct 2026 01:26PM UTC coverage: 74.782% (+0.2%) from 74.57%
38742671777

Pull #2525

github

web-flow
Merge 4fcc7cc8f into 7e7928d01
Pull Request #2525: #2452: Fixed checkstyle violations in cli module

5866 of 8721 branches covered (67.26%)

Branch coverage included in aggregate %.

15343 of 19640 relevant lines covered (78.12%)

3.36 hits per line

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

72.92
cli/src/main/java/com/devonfw/tools/ide/version/VersionRangeRelation.java
1
package com.devonfw.tools.ide.version;
2

3
/**
4
 * {@link Enum} with the available types how {@link VersionRange}s can relate to each other. Examples are given by the following table:
5
 * <table border="1">
6
 *   <tr>
7
 *     <th>range1</th>
8
 *     <th>range2</th>
9
 *     <th>relation</th>
10
 *   </tr>
11
 *   <tr>
12
 *     <td>[2.0,5.0)</td>
13
 *     <td>(3.0,5.0]</td>
14
 *     <td>{@link #OVERLAPPING}</td>
15
 *   </tr>
16
 *   <tr>
17
 *     <td>[2.0,3.0]</td>
18
 *     <td>[3.0,5.0]</td>
19
 *     <td>{@link #OVERLAPPING}</td>
20
 *   </tr>
21
 *   <tr>
22
 *     <td>[2.0,3.0)</td>
23
 *     <td>[3.0,5.0]</td>
24
 *     <td>{@link #CONNECTED}</td>
25
 *   </tr>
26
 *   <tr>
27
 *     <td>[2.0,3.0]</td>
28
 *     <td>(3.0,5.0]</td>
29
 *     <td>{@link #CONNECTED}</td>
30
 *   </tr>
31
 *   <tr>
32
 *     <td>[2.0,2.2]</td>
33
 *     <td>[2.3,5.0]</td>
34
 *     <td>{@link #CONNECTED_LOOSELY}</td>
35
 *   </tr>
36
 *   <tr>
37
 *     <td>[2.0,3.0]</td>
38
 *     <td>[4.0,5.0]</td>
39
 *     <td>{@link #DISJUNCT}</td>
40
 *   </tr>
41
 *   <tr>
42
 *     <td>[2.0,2.2)</td>
43
 *     <td>(2.2,5.0]</td>
44
 *     <td>{@link #DISJUNCT}</td>
45
 *   </tr>
46
 * </table>
47
 * For readability, we sorted the {@link VersionRange}s in the examples from the table above but there is no order in the {@link VersionRange}s to be
48
 * considered.
49
 * Further, the last example seems to raise some question: Why is a gap of "(2.2, 2.3)" accepted as {@link #CONNECTED_LOOSELY} while a gap of only
50
 * exactly "[2.2, 2.2]" is not?
51
 * From a strictly mathematical point of view this seems confusing. However, in the last example version "2.2" is considered to be known and is
52
 * explicitly not included in both ranges.
53
 * In contrast, the example for {@link #CONNECTED_LOOSELY} explicitly includes versions "2.2" and "2.3" and if we assume a strict versioning schema, then
54
 * "2.3" is the {@link VersionIdentifier#incrementSegment(int, boolean) next version build by incrementing only the last digit}. Even though in math
55
 * there are infinite numbers in "(2.2, 2.3)" but from a pragmatical view
56
 * of a product versioning scheme we could assume that "(2.2, 2.3)" is actually empty.
57
 *
58
 * @see VersionRange#union(VersionRange, VersionRangeRelation)
59
 */
60
public enum VersionRangeRelation {
3 ✔
61

62
  /** The {@link VersionRange}s are disjunct so there is no value contained in all of them. */
63
  DISJUNCT,
6 ✔
64

65
  /**
66
   * The {@link VersionRange}s are connected loosely so the maximum of the {@link VersionRange#getMin() minimums} is equal to the minimum of the *
67
   * {@link VersionRange#getMax() maximums} and that value is {@link VersionRange#contains(VersionIdentifier) contained} in only one of them.
68
   */
69
  CONNECTED_LOOSELY,
6 ✔
70

71
  /**
72
   * The {@link VersionRange}s are connected so the maximum of the {@link VersionRange#getMin() minimums} is equal to the minimum of the
73
   * {@link VersionRange#getMax() maximums} and that value is {@link VersionRange#contains(VersionIdentifier) contained} in only one of them.
74
   */
75
  CONNECTED,
6 ✔
76

77
  /**
78
   * The {@link VersionRange}s overlap so the maximum of the {@link VersionRange#getMin() minimums} is {@link VersionIdentifier#isLessOrEqual less or equal} to
79
   * the minimum of the {@link VersionRange#getMax() maximums} and if they are equal that value must be
80
   * {@link VersionRange#contains(VersionIdentifier) contained} in the {@link VersionRange}s.
81
   */
82
  OVERLAPPING;
6 ✔
83

84
  /**
85
   * @param maxMin the maximum of the {@link VersionRange#getMin() minimums}.
86
   * @param maxMinExclusive {@code true} if {@code maxMin} is exclusive, {@code false} otherwise.
87
   * @param minMax the minimum of the {@link VersionRange#getMax() maximums}.
88
   * @param minMaxExclusive {@code true} if {@code minMax} is exclusive, {@code false} otherwise.
89
   * @return the {@link VersionRangeRelation} for the given situation.
90
   */
91
  static VersionRangeRelation of(VersionIdentifier maxMin, boolean maxMinExclusive, VersionIdentifier minMax, boolean minMaxExclusive) {
92

93
    if ((minMax == null) || (maxMin == null)) {
4 !
94
      // "(,1]" and "(,10)" overlaps also "(1,)" and "(2,)" as well as "(,)" and "(,)" do
95
      assert (minMax != null) || minMaxExclusive;
×
96
      assert (maxMin != null) || maxMinExclusive;
×
97
      return OVERLAPPING;
×
98
    }
99
    VersionComparisonResult comparison = minMax.compareVersion(maxMin);
4 ✔
100
    if (comparison.isGreater()) {
3 ✔
101
      return OVERLAPPING; // "[1.0,2.1)" and "(2.0,3.0]" overlap
2 ✔
102
    } else if (comparison.isEqual()) {
3 ✔
103
      if (!maxMinExclusive && !minMaxExclusive) {
4 ✔
104
        return OVERLAPPING;
2 ✔
105
      } else if (maxMinExclusive && minMaxExclusive) {
4 ✔
106
        return DISJUNCT;
2 ✔
107
      } else {
108
        return CONNECTED;
2 ✔
109
      }
110
    } else { // less than
111
      VersionIdentifier minMaxNext = minMax.incrementLastDigit(true);
4 ✔
112
      if (minMaxNext.isGreaterOrEqual(maxMin)) {
4 ✔
113
        return CONNECTED_LOOSELY;
2 ✔
114
      }
115
    }
116
    return DISJUNCT;
2 ✔
117
  }
118
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc