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

devonfw / IDEasy / 9907372175

12 Jul 2024 11:49AM UTC coverage: 61.142% (-0.02%) from 61.162%
9907372175

push

github

hohwille
fixed tests

1997 of 3595 branches covered (55.55%)

Branch coverage included in aggregate %.

5296 of 8333 relevant lines covered (63.55%)

2.8 hits per line

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

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

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

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

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

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

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

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

42
    return compareVersion(other).isLess();
×
43
  }
44

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

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

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

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

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

69
}
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