Skip to content

Commit

Permalink
#158: added jackson json annotation
Browse files Browse the repository at this point in the history
  • Loading branch information
MattesMrzik committed Jan 2, 2024
1 parent e50749a commit e6bdbf2
Showing 1 changed file with 30 additions and 25 deletions.
55 changes: 30 additions & 25 deletions cli/src/main/java/com/devonfw/tools/ide/version/VersionRange.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package com.devonfw.tools.ide.version;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;

/**
* Container for a range of versions. The lower and upper bounds can be exclusive or inclusive. If a bound is null, it
* means that this direction is unbounded. The boolean defining whether this bound is inclusive or exclusive is ignored
Expand All @@ -25,6 +28,31 @@ public final class VersionRange implements Comparable<VersionRange> {

private static final String END_INCLUDING_SUFFIX = "]";

public static String getVersionSeparator() {

return VERSION_SEPARATOR;
}

public static String getStartExcludingPrefix() {

return START_EXCLUDING_PREFIX;
}

public static String getStartIncludingPrefix() {

return START_INCLUDING_PREFIX;
}

public static String getEndExcludingSuffix() {

return END_EXCLUDING_SUFFIX;
}

public static String getEndIncludingSuffix() {

return END_INCLUDING_SUFFIX;
}

/**
* The constructor.
*
Expand Down Expand Up @@ -193,6 +221,7 @@ public boolean equals(Object obj) {
}

@Override
@JsonValue
public String toString() {

StringBuilder sb = new StringBuilder();
Expand All @@ -212,6 +241,7 @@ public String toString() {
* @param value the {@link #toString() string representation} of a {@link VersionRange} to parse.
* @return the parsed {@link VersionRange}.
*/
@JsonCreator
public static VersionRange of(String value) {

boolean leftIsExclusive = false;
Expand Down Expand Up @@ -249,29 +279,4 @@ public static VersionRange of(String value) {
return new VersionRange(min, max, leftIsExclusive, rightIsExclusive);
}

public static String getVersionSeparator() {

return VERSION_SEPARATOR;
}

public static String getStartExcludingPrefix() {

return START_EXCLUDING_PREFIX;
}

public static String getStartIncludingPrefix() {

return START_INCLUDING_PREFIX;
}

public static String getEndExcludingSuffix() {

return END_EXCLUDING_SUFFIX;
}

public static String getEndIncludingSuffix() {

return END_INCLUDING_SUFFIX;
}

}

0 comments on commit e6bdbf2

Please sign in to comment.