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

devonfw / IDEasy / 12181235589

05 Dec 2024 01:58PM UTC coverage: 66.902% (-0.02%) from 66.917%
12181235589

push

github

web-flow
#508: enabled autocompletion for commandlet options (#833)

2527 of 4130 branches covered (61.19%)

Branch coverage included in aggregate %.

6577 of 9478 relevant lines covered (69.39%)

3.06 hits per line

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

86.49
cli/src/main/java/com/devonfw/tools/ide/validation/ValidationState.java
1
package com.devonfw.tools.ide.validation;
2

3
/**
4
 * Implementation of {@link ValidationResult} as a mutable state that can collect errors dynamically.
5
 */
6
public class ValidationState implements ValidationResult {
7

8
  private final String propertyName;
9

10
  private StringBuilder errorMessage;
11

12
  /**
13
   * The default constructor for no property.
14
   */
15
  public ValidationState() {
16
    this(null);
×
17
  }
×
18

19
  /**
20
   * @param propertyName the name of the property to validate.
21
   */
22
  public ValidationState(String propertyName) {
2✔
23
    this.propertyName = propertyName;
3✔
24
  }
1✔
25

26
  @Override
27
  public boolean isValid() {
28
    return (this.errorMessage == null);
7✔
29
  }
30

31
  @Override
32
  public String getErrorMessage() {
33
    if (this.errorMessage == null) {
3✔
34
      return null;
2✔
35
    }
36
    return this.errorMessage.toString();
4✔
37
  }
38

39
  /**
40
   * @param error the error message to add to this {@link ValidationState}.
41
   */
42
  public void addErrorMessage(String error) {
43
    if (this.errorMessage == null) {
3✔
44
      if (this.propertyName == null) {
3!
45
        this.errorMessage = new StringBuilder(error.length() + 1);
×
46
        this.errorMessage.append('\n');
×
47
      } else {
48
        this.errorMessage = new StringBuilder(error.length() + propertyName.length() + 21); // 21 for the static text below
13✔
49
        this.errorMessage.append(String.format("Error in property %s:", propertyName));
13✔
50
        this.errorMessage.append('\n');
6✔
51
      }
52
    } else {
53
      this.errorMessage.append('\n');
5✔
54
    }
55
    this.errorMessage.append(error);
5✔
56
  }
1✔
57

58
  /**
59
   * @param result the {@link ValidationResult} to add to this {@link ValidationState}.
60
   */
61
  public void add(ValidationResult result) {
62
    if (!result.isValid()) {
3✔
63
      if (this.errorMessage == null) {
3✔
64
        this.errorMessage = new StringBuilder(result.getErrorMessage().length());
8✔
65
        this.errorMessage.append(result.getErrorMessage());
7✔
66
      } else {
67
        addErrorMessage(result.getErrorMessage());
4✔
68
      }
69
    }
70
  }
1✔
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

© 2026 Coveralls, Inc