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

devonfw / IDEasy / 12236799868

09 Dec 2024 01:37PM UTC coverage: 67.035% (+0.08%) from 66.953%
12236799868

push

github

web-flow
#799: fix zip extraction to preserve file attributes (#835)

2543 of 4142 branches covered (61.4%)

Branch coverage included in aggregate %.

6608 of 9509 relevant lines covered (69.49%)

3.06 hits per line

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

87.8
cli/src/main/java/com/devonfw/tools/ide/io/AbstractIdeProgressBar.java
1
package com.devonfw.tools.ide.io;
2

3
/**
4
 * Abstract implementation of {@link IdeProgressBar}.
5
 */
6
public abstract class AbstractIdeProgressBar implements IdeProgressBar {
7

8
  /** @see #getTitle() */
9
  protected final String title;
10

11
  /** @see #getMaxSize() */
12
  protected final long maxSize;
13

14
  /** @see #getUnitName() */
15
  protected final String unitName;
16

17
  /** @see #getUnitSize() */
18
  protected final long unitSize;
19

20
  private long currentProgress;
21

22
  /**
23
   * The constructor.
24
   *
25
   * @param title the {@link #getTitle() title}.
26
   * @param maxSize the {@link #getMaxSize() maximum size}.
27
   * @param unitName the {@link #getUnitName() unit name}.
28
   * @param unitSize the {@link #getUnitSize() unit size}.
29
   */
30
  public AbstractIdeProgressBar(String title, long maxSize, String unitName, long unitSize) {
31

32
    super();
2✔
33
    this.title = title;
3✔
34
    this.maxSize = maxSize;
3✔
35
    this.unitName = unitName;
3✔
36
    this.unitSize = unitSize;
3✔
37
  }
1✔
38

39
  @Override
40
  public String getTitle() {
41

42
    return this.title;
×
43
  }
44

45
  @Override
46
  public long getMaxSize() {
47

48
    return this.maxSize;
3✔
49
  }
50

51
  @Override
52
  public String getUnitName() {
53

54
    return this.unitName;
×
55
  }
56

57
  @Override
58
  public long getUnitSize() {
59

60
    return this.unitSize;
×
61
  }
62

63
  /**
64
   * Increases the progress bar by given step size.
65
   *
66
   * @param stepSize size to step by.
67
   * @param currentProgress current progress state (used for tests only).
68
   */
69
  protected abstract void doStepBy(long stepSize, long currentProgress);
70

71
  /**
72
   * Sets the progress bar to given step position while making sure to avoid overflow.
73
   *
74
   * @param stepPosition position to set to.
75
   */
76
  protected void stepTo(long stepPosition) {
77

78
    if ((this.maxSize > 0) && (stepPosition > this.maxSize)) {
10!
79
      stepPosition = this.maxSize; // clip to max avoiding overflow
×
80
    }
81
    this.currentProgress = stepPosition;
3✔
82
    doStepTo(stepPosition);
3✔
83
  }
1✔
84

85
  /**
86
   * Sets the progress bar to given step position.
87
   *
88
   * @param stepPosition position to set to.
89
   */
90
  protected abstract void doStepTo(long stepPosition);
91

92
  @Override
93
  public void stepBy(long stepSize) {
94

95
    this.currentProgress += stepSize;
6✔
96
    if (this.maxSize > 0) {
5✔
97
      // check if maximum overflow
98
      if (this.currentProgress > this.maxSize) {
6✔
99
        this.currentProgress = this.maxSize;
4✔
100
        stepTo(this.maxSize);
4✔
101
        return;
1✔
102
      }
103
    }
104

105
    doStepBy(stepSize, this.currentProgress);
5✔
106
  }
1✔
107

108
  @Override
109
  public long getCurrentProgress() {
110

111
    return this.currentProgress;
3✔
112
  }
113

114
  @Override
115
  public void close() {
116
    if (this.maxSize < 0) {
5✔
117
      return;
1✔
118
    }
119

120
    if (this.currentProgress < this.maxSize) {
6✔
121
      stepTo(this.maxSize);
4✔
122
    }
123
  }
1✔
124

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

© 2026 Coveralls, Inc