Changeset 15591 in josm


Ignore:
Timestamp:
2019-12-13T23:04:23+01:00 (6 years ago)
Author:
Don-vip
Message:

fix #18408 - Add trim_list mapCSS function (patch by taylor.smock)

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/Functions.java

    r15323 r15591  
    983983
    984984    /**
     985     * Trim whitespaces from the strings {@code strings}.
     986     *
     987     * @param strings The list of strings to strip
     988     * @return The resulting string
     989     * @see Utils#strip
     990     * @since 15591
     991     */
     992    public static List<String> trim_list(List<String> strings) {
     993        return strings.stream().map(Utils::strip).filter(str -> !str.isEmpty()).collect(Collectors.toList());
     994    }
     995
     996    /**
    985997     * Check if two strings are similar, but not identical, i.e., have a Levenshtein distance of 1 or 2.
    986998     * @param string1 first string to compare
  • trunk/test/unit/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSParserTest.java

    r15323 r15591  
    325325    }
    326326
     327    /**
     328     * Test case for {@link Functions#trim_list}
     329     */
     330    @Test
     331    public void testTrimList() {
     332        List<String> trimmed = Functions.trim_list(Arrays.asList(" A1 ", "A2", " A3", "A4 ", ""));
     333        assertEquals(4, trimmed.size());
     334        assertEquals("A1", trimmed.get(0));
     335        assertEquals("A2", trimmed.get(1));
     336        assertEquals("A3", trimmed.get(2));
     337        assertEquals("A4", trimmed.get(3));
     338    }
     339
    327340    @Test
    328341    public void testTicket8568() throws Exception {
Note: See TracChangeset for help on using the changeset viewer.