Changeset 17800 in josm
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/Selector.java
r17781 r17800 8 8 import java.text.MessageFormat; 9 9 import java.util.ArrayList; 10 import java.util.Arrays; 10 11 import java.util.Collection; 11 12 import java.util.Collections; … … 215 216 return; 216 217 int count = counter.getAsInt(); 217 if (link. conds == null || link.conds.isEmpty()) {218 if (link.getConditions().isEmpty()) { 218 219 // index is not needed, we can avoid the sequential search below 219 220 e.parent = parent; … … 235 236 236 237 private boolean firstAndLastOnly() { 237 return link. conds.stream().allMatch(c -> c instanceof IndexCondition && ((IndexCondition) c).isFirstOrLast);238 return link.getConditions().stream().allMatch(c -> c instanceof IndexCondition && ((IndexCondition) c).isFirstOrLast); 238 239 } 239 240 … … 574 575 } 575 576 } else if (ChildOrParentSelectorType.CHILD == type 576 && link.conds != null && !link.conds.isEmpty()577 && link. conds.get(0) instanceof OpenEndPseudoClassCondition) {577 && !link.getConditions().isEmpty() 578 && link.getConditions().get(0) instanceof OpenEndPseudoClassCondition) { 578 579 if (e.osm instanceof INode) { 579 580 e.osm.visitReferrers(new MultipolygonOpenEndFinder(e)); … … 638 639 abstract class AbstractSelector implements Selector { 639 640 640 pr otectedfinalList<Condition>conds;641 private final Condition[] conds; 641 642 642 643 protected AbstractSelector(List<Condition> conditions) { 643 this.conds = Utils.toUnmodifiableList(conditions);644 this.conds = conditions.toArray(new Condition[0]); 644 645 } 645 646 … … 666 667 @Override 667 668 public List<Condition> getConditions() { 668 return conds;669 return Arrays.asList(conds); 669 670 } 670 671 } … … 703 704 @Override 704 705 public String toString() { 705 return "LinkSelector{conditions=" + conds+ '}';706 return "LinkSelector{conditions=" + getConditions() + '}'; 706 707 } 707 708 } … … 832 833 return base 833 834 + (Range.ZERO_TO_INFINITY.equals(range) ? "" : range) 834 + ( conds != null ? conds.stream().map(String::valueOf).collect(Collectors.joining("")): "")835 + (getConditions().stream().map(String::valueOf).collect(Collectors.joining(""))) 835 836 + (subpart != null && subpart != Subpart.DEFAULT_SUBPART ? ("::" + subpart) : ""); 836 837 } -
trunk/test/unit/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSParserTest.java
r17780 r17800 79 79 @Test 80 80 void testClassCondition() throws Exception { 81 List<Condition> conditions = ((Selector.GeneralSelector)getParser("way[name=X].highway:closed").selector()).conds;81 List<Condition> conditions = getParser("way[name=X].highway:closed").selector().getConditions(); 82 82 assertTrue(conditions.get(0) instanceof SimpleKeyValueCondition); 83 83 assertTrue(conditions.get(0).applies(getEnvironment("name", "X"))); … … 89 89 @Test 90 90 void testPseudoClassCondition() throws Exception { 91 Condition c0 = ((Selector.GeneralSelector)getParser("way:area-style").selector()).conds.get(0);92 Condition c1 = ((Selector.GeneralSelector)getParser("way!:area-style").selector()).conds.get(0);93 Condition c2 = ((Selector.GeneralSelector)getParser("way!:areaStyle").selector()).conds.get(0);94 Condition c3 = ((Selector.GeneralSelector)getParser("way!:area_style").selector()).conds.get(0);91 Condition c0 = getParser("way:area-style").selector().getConditions().get(0); 92 Condition c1 = getParser("way!:area-style").selector().getConditions().get(0); 93 Condition c2 = getParser("way!:areaStyle").selector().getConditions().get(0); 94 Condition c3 = getParser("way!:area_style").selector().getConditions().get(0); 95 95 assertEquals(":areaStyle", c0.toString()); 96 96 assertEquals("!:areaStyle", c1.toString());
Note:
See TracChangeset
for help on using the changeset viewer.