Skip to content

Commit 312afdd

Browse files
committed
devonfw#103: updated to be in line with devonfw#158
1 parent fd64100 commit 312afdd

File tree

1 file changed

+18
-17
lines changed

1 file changed

+18
-17
lines changed

cli/src/main/java/com/devonfw/tools/ide/version/VersionRange.java

+18-17
Original file line numberDiff line numberDiff line change
@@ -244,23 +244,9 @@ public String toString() {
244244
@JsonCreator
245245
public static VersionRange of(String value) {
246246

247-
boolean leftIsExclusive = false;
248-
boolean rightIsExclusive = false;
249-
250-
if (value.startsWith(START_EXCLUDING_PREFIX)) {
251-
leftIsExclusive = true;
252-
value = value.substring(START_EXCLUDING_PREFIX.length());
253-
}
254-
if (value.startsWith(START_INCLUDING_PREFIX)) {
255-
value = value.substring(START_INCLUDING_PREFIX.length());
256-
}
257-
if (value.endsWith(END_EXCLUDING_SUFFIX)) {
258-
rightIsExclusive = true;
259-
value = value.substring(0, value.length() - END_EXCLUDING_SUFFIX.length());
260-
}
261-
if (value.endsWith(END_INCLUDING_SUFFIX)) {
262-
value = value.substring(0, value.length() - END_EXCLUDING_SUFFIX.length());
263-
}
247+
boolean leftIsExclusive = value.startsWith(START_EXCLUDING_PREFIX);
248+
boolean rightIsExclusive = value.endsWith(END_EXCLUDING_SUFFIX);
249+
value = removeAffixes(value);
264250

265251
int index = value.indexOf(VERSION_SEPARATOR);
266252
if (index == -1) {
@@ -279,4 +265,19 @@ public static VersionRange of(String value) {
279265
return new VersionRange(min, max, leftIsExclusive, rightIsExclusive);
280266
}
281267

268+
private static String removeAffixes(String value) {
269+
270+
if (value.startsWith(START_EXCLUDING_PREFIX)) {
271+
value = value.substring(START_EXCLUDING_PREFIX.length());
272+
} else if (value.startsWith(START_INCLUDING_PREFIX)) {
273+
value = value.substring(START_INCLUDING_PREFIX.length());
274+
}
275+
if (value.endsWith(END_EXCLUDING_SUFFIX)) {
276+
value = value.substring(0, value.length() - END_EXCLUDING_SUFFIX.length());
277+
} else if (value.endsWith(END_INCLUDING_SUFFIX)) {
278+
value = value.substring(0, value.length() - END_EXCLUDING_SUFFIX.length());
279+
}
280+
return value;
281+
}
282+
282283
}

0 commit comments

Comments
 (0)