Skip to content
Snippets Groups Projects

Fix Java version filters #18

Merged Martin Lowe requested to merge github/fork/autumnfound/malowe/master/18 into master

Fixed lookup of Java versions in listing versions to convert string values like 1.7 to a number 7, to take advantage of raw number comparisons. Fixed issue where version filters weren't properly being restricted to a single document.

Signed-off-by: Martin Lowe martin.lowe@eclipse-foundation.org

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Christopher Guindon
  • 13 * Used to handle the conversion of Java versions to and from storage mediums.
    14 *
    15 * @author Martin Lowe
    16 *
    17 */
    18 public class JavaVersionHelper {
    19 private static final Pattern MAJOR_VERSION_CHECK = Pattern.compile("^\\d\\.([^\\.\\D]+)");
    20
    21 /**
    22 * Converts value to strip out parts of Java version string that cause issues
    23 * with natural number sorting in databases.
    24 *
    25 * @param val the java version string to convert (e.g. 1.7, 1.10)
    26 * @return modified and more sortable version string
    27 */
    28 public static final String convertToDBSafe(String val) {
  • Christopher Guindon
  • 40 int idx = out.indexOf('.');
    41 if (idx > -1) {
    42 out = out.substring(0, idx);
    43 }
    44
    45 return out;
    46 }
    47
    48 /**
    49 * Converts the sortable DB value for the Java version to something more in line
    50 * with what is expected by the user.
    51 *
    52 * @param val the sortable stored version string
    53 * @return display value of the sortable Java version
    54 */
    55 public static final String convertToDisplayValue(String val) {
    • Created by: mbarbero

      Add some unit tests as well. I'm pretty sure we don't want to display 1.11 for Java 11 and AFAICT, this code does exactly that.

  • Created by mbarbero

    Review: Approved

  • Please register or sign in to reply
    Loading