Ticket #18085: 18085.patch
File 18085.patch, 2.1 KB (added by , 6 years ago) |
---|
-
src/org/openstreetmap/josm/gui/mappaint/mapcss/Functions.java
571 571 } 572 572 573 573 /** 574 * Get unique values 575 * @param values A list of values that may have duplicates 576 * @return A list with no duplicates 577 * @since xxx 578 */ 579 public static List<String> uniq(String... values) { 580 return uniq_list(Arrays.asList(values)); 581 } 582 583 /** 584 * Get unique values 585 * @param values A list of values that may have duplicates 586 * @return A list with no duplicates 587 * @since xxx 588 */ 589 public static List<String> uniq_list(List<String> values) { 590 return values.stream().distinct().collect(Collectors.toList()); 591 } 592 593 /** 574 594 * Returns the role of current object in parent relation, or role of child if current object is a relation. 575 595 * @param env the environment 576 596 * @return role of current object in parent relation, or role of child if current object is a relation -
test/unit/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSParserTest.java
465 465 } 466 466 467 467 @Test 468 public void testUniqueValues() throws Exception { 469 assertEquals(Arrays.asList(new String[] {"alpha", "beta"}), 470 Functions.uniq("alpha", "alpha", "alpha", "beta")); 471 assertEquals(Arrays.asList(new String[] {"one", "two", "three"}), 472 Functions.uniq_list(Arrays.asList(new String[] {"one", "one", "two", "two", "two", "three"}))); 473 } 474 475 @Test 468 476 public void testCountRoles() throws Exception { 469 477 DataSet ds = new DataSet(); 470 478 Way way1 = TestUtils.newWay("highway=residential name=1",