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

devonfw / IDEasy / 25333796320

04 May 2026 05:40PM UTC coverage: 70.645% (-0.002%) from 70.647%
25333796320

push

github

web-flow
#1238: User-defined MAVEN_ARGS appends and no longer overwrites IDEasy's defaults (#1825)

4386 of 6860 branches covered (63.94%)

Branch coverage included in aggregate %.

11312 of 15361 relevant lines covered (73.64%)

3.11 hits per line

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

55.56
cli/src/main/java/com/devonfw/tools/ide/variable/VariableDefinition.java
1
package com.devonfw.tools.ide.variable;
2

3
import java.util.Collection;
4

5
import com.devonfw.tools.ide.context.IdeContext;
6
import com.devonfw.tools.ide.environment.EnvironmentVariables;
7
import com.devonfw.tools.ide.environment.VariableLine;
8

9
/**
10
 * Interface for a definition of a variable.
11
 *
12
 * @param <V> the {@link #getValueType() value type}.
13
 */
14
public interface VariableDefinition<V> {
15

16
  /**
17
   * @return the name of the variable.
18
   */
19
  String getName();
20

21
  /**
22
   * @return the optional legacy name that is still supported for downward compatibility. May be {@code null} if undefined (no legacy support).
23
   */
24
  String getLegacyName();
25

26
  /**
27
   * @return the {@link Class} reflecting the type of the variable value.
28
   */
29
  Class<V> getValueType();
30

31
  /**
32
   * @param context the {@link IdeContext}.
33
   * @return the default value. May be {@code null}.
34
   */
35
  V getDefaultValue(IdeContext context);
36

37
  /**
38
   * @param context the {@link IdeContext}.
39
   * @return the default value as {@link String}. May be {@code null}.
40
   * @see #getDefaultValue(IdeContext)
41
   * @see #toString(Object, IdeContext)
42
   */
43
  default String getDefaultValueAsString(IdeContext context) {
44

45
    V value = getDefaultValue(context);
4✔
46
    if (value == null) {
2✔
47
      return null;
2✔
48
    }
49
    return toString(value, context);
5✔
50
  }
51

52
  /**
53
   * @return {@code true} if the {@link #getDefaultValue(IdeContext) default value} shall be used without any
54
   * {@link EnvironmentVariables#get(String) variable lookup} (to prevent odd overriding of build in variables like IDE_HOME), {@code false} otherwise
55
   * (overriding of default value is allowed and intended).
56
   */
57
  boolean isForceDefaultValue();
58

59
  /**
60
   * @return {@code true} if a user-defined value shall be extended by appending the {@link #getDefaultValue(IdeContext) default value} (separated by a space),
61
   * {@code false} otherwise (default, user value fully replaces the default). This allows users to extend a variable like {@code MAVEN_ARGS} without losing
62
   * IDEasy's own defaults.
63
   */
64
  default boolean isDefaultValueAppended() {
65

66
    return false;
×
67
  }
68

69
  /**
70
   * @param value the value as {@link String}. May NOT be {@code null}.
71
   * @param context the {@link IdeContext}.
72
   * @return the value converted to the {@link #getValueType() value type}.
73
   */
74
  V fromString(String value, IdeContext context);
75

76
  /**
77
   * @return {@code true} if the variable needs to be exported, {@code false} otherwise.
78
   */
79
  boolean isExport();
80

81
  /**
82
   * @param value the typed value.
83
   * @param context the {@link IdeContext}.
84
   * @return the value converted to {@link String}.
85
   */
86
  default String toString(V value, IdeContext context) {
87

88
    if (value == null) {
2!
89
      return "";
×
90
    } else if (value instanceof Collection<?> collection) {
3!
91
      StringBuilder sb = new StringBuilder();
×
92
      for (Object element : collection) {
×
93
        if (sb.length() > 0) {
×
94
          sb.append(',');
×
95
        }
96
        sb.append(element);
×
97
      }
×
98
      return sb.toString();
×
99
    }
100
    return value.toString();
3✔
101
  }
102

103
  /**
104
   * @param context the {@link IdeContext}.
105
   * @return the value of the variable of this {@link VariableDefinition}.
106
   */
107
  V get(IdeContext context);
108

109
  /**
110
   * @param line the {@link VariableLine} that potentially needs to be migrated.
111
   * @return the original {@link VariableLine} or a migrated copy of it.
112
   */
113
  default VariableLine migrateLine(VariableLine line) {
114

115
    String name = line.getName();
3✔
116
    if (name != null) {
2!
117
      String newName = getName();
3✔
118
      if (!name.equals(newName)) {
4✔
119
        return line.withName(newName);
4✔
120
      }
121
    }
122
    return line;
2✔
123
  }
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